allow scale when drawing character (and other minor stuff)

This commit is contained in:
jrkb 2023-04-08 13:40:17 +02:00
parent f4ad2679c9
commit 5d52383aaa
3 changed files with 7 additions and 2 deletions

View file

@ -36,7 +36,7 @@ class Layer {
bool mirror_y = false; bool mirror_y = false;
float mirror_y_distance = 0; float mirror_y_distance = 0;
float letterDelay = 0; float letterDelay = 0;
string text = "abcdefghijklmnoprstuvqxyzABUIWERJSD"; string text = "abc";
string fontPath; string fontPath;
}; };
@ -47,6 +47,7 @@ class Layer {
glm::vec3 position = glm::vec3(0, 0, 0), glm::vec3 position = glm::vec3(0, 0, 0),
glm::vec4 color = glm::vec4(1, 1, 1, 1), glm::vec4 color = glm::vec4(1, 1, 1, 1),
float rotation = 0, float rotation = 0,
float scale = 1,
ofxVariableLab::FontVariation fontVariation = ofxVariableLab::FontVariation()) = 0; ofxVariableLab::FontVariation fontVariation = ofxVariableLab::FontVariation()) = 0;
virtual void setProps(const Props & props) = 0; virtual void setProps(const Props & props) = 0;
virtual const Props & getProps() const = 0; virtual const Props & getProps() const = 0;

View file

@ -164,6 +164,7 @@ void MsdfLayer::drawCharacter(const char character,
glm::vec3 position, glm::vec3 position,
glm::vec4 color, glm::vec4 color,
float rotation, float rotation,
float scale,
ofxVariableLab::FontVariation fontVariation){ ofxVariableLab::FontVariation fontVariation){
const ofImage & atlasImage = atlas->getAtlasImage(); const ofImage & atlasImage = atlas->getAtlasImage();
ofDisableAlphaBlending(); ofDisableAlphaBlending();
@ -250,7 +251,7 @@ void MsdfLayer::drawCharacter(const char character,
shader->setUniform2f("scale_b", scale_b); shader->setUniform2f("scale_b", scale_b);
shader->setUniform1f("msdf_mix", mix); shader->setUniform1f("msdf_mix", mix);
//ofRotateDeg(rotation, 0, 0, 1); //ofRotateDeg(rotation, 0, 0, 1);
atlasImage.draw(0, 0, w, h); atlasImage.draw(0, 0, w * scale, h * scale);
shader->end(); shader->end();
ofPopMatrix(); ofPopMatrix();
ofPopStyle(); ofPopStyle();
@ -275,6 +276,8 @@ const Layer::Type & MsdfLayer::getType() const {
void MsdfLayer::setAtlas(shared_ptr <ofxMsdfgen::Atlas> _atlas){ void MsdfLayer::setAtlas(shared_ptr <ofxMsdfgen::Atlas> _atlas){
atlas = _atlas; atlas = _atlas;
// TODO: this does not seem proper
propsBuffer[0].fontSize_px = atlas->settings.scale;
} }
shared_ptr <ofxMsdfgen::Atlas> MsdfLayer::getAtlas() const { shared_ptr <ofxMsdfgen::Atlas> MsdfLayer::getAtlas() const {
return atlas; return atlas;

View file

@ -17,6 +17,7 @@ class MsdfLayer : public Layer {
glm::vec3 position = glm::vec3(0, 0, 0), glm::vec3 position = glm::vec3(0, 0, 0),
glm::vec4 color = glm::vec4(1, 1, 1, 1), glm::vec4 color = glm::vec4(1, 1, 1, 1),
float rotation = 0, float rotation = 0,
float scale = 1,
ofxVariableLab::FontVariation fontVariation = ofxVariableLab::FontVariation()) override; ofxVariableLab::FontVariation fontVariation = ofxVariableLab::FontVariation()) override;
void setProps(const Props & props) override; void setProps(const Props & props) override;
const Props & getProps() const override; const Props & getProps() const override;