draw Layer letters on xy-baseline (no kerning)
This commit is contained in:
parent
9e8ddb6558
commit
7c7485e2f0
3 changed files with 58 additions and 10 deletions
|
@ -39,8 +39,15 @@ void MsdfLayer::draw(glm::vec3 position) const {
|
|||
shader->end();
|
||||
|
||||
ofPushMatrix();
|
||||
atlas->getAtlasImage().draw(0, 0);
|
||||
ofTranslate(position);
|
||||
ofPushStyle();
|
||||
ofSetColor(ofColor::pink);
|
||||
ofDrawLine(glm::vec2(0, 0), glm::vec2(ofGetWidth(), 0));
|
||||
ofPopStyle();
|
||||
//atlas->getAtlasImage().draw(0, 0);
|
||||
//cout << "drawing letters (" << ofToString(propsBuffer.size()) << ")" << endl;
|
||||
char previous_c;
|
||||
bool firstLetter = true;
|
||||
for(const char c : propsBuffer[0].text){
|
||||
ofxMsdfgen::GlyphGeometry gg = atlas->getGlyphGeometry(c);
|
||||
int x, y, w, h;
|
||||
|
@ -51,16 +58,14 @@ void MsdfLayer::draw(glm::vec3 position) const {
|
|||
ofLogError("MsdfLayer::draw") << "y smaller 0, this is not good" << endl;
|
||||
}
|
||||
ofPushStyle();
|
||||
ofNoFill();
|
||||
ofSetColor(ofFloatColor(sin(ofGetElapsedTimeMicros() * 0.0001) * 0.5 + 0.5, 0, 0, 1));
|
||||
double pl, pb, pr, pt,
|
||||
il, ib, ir, it;
|
||||
gg.getQuadPlaneBounds(pl, pb, pr, pt);
|
||||
gg.getQuadAtlasBounds(il, ib, ir, it);
|
||||
|
||||
ofPushMatrix();
|
||||
float magic = ofMap(sin(ofGetElapsedTimeMicros() * 0.000001), -1, 1, 1, 1000);
|
||||
ofTranslate(pl * magic, pt * magic, 0);
|
||||
float magic = ofMap(sin(ofGetElapsedTimeMicros() * 0.000001), -1, 1, 1, 200);
|
||||
magic = atlas->settings.scale;
|
||||
//if(ofGetFrameNum() % 30 == 0){
|
||||
//cout << "drawing letter " << c << endl
|
||||
//<< "\tpl: " << ofToString(pl)
|
||||
|
@ -70,14 +75,57 @@ void MsdfLayer::draw(glm::vec3 position) const {
|
|||
//<< endl;
|
||||
//}
|
||||
|
||||
ofPushMatrix();
|
||||
for(int i = 0; i < 2; i++){
|
||||
if(i == 1){
|
||||
ofRotateDeg(90);
|
||||
ofTranslate(200, -150, 0);
|
||||
}
|
||||
ofNoFill();
|
||||
ofSetColor(ofColor::white);
|
||||
ofDrawLine(glm::vec2(0, 90), glm::vec2(0, 140));
|
||||
ofSetColor(ofColor::lightGray);
|
||||
for(int i = 1; i < 3; i++){
|
||||
ofDrawLine(glm::vec2(i * 20, 90), glm::vec2(i * 20, 140));
|
||||
}
|
||||
ofFill();
|
||||
if(i == 0){
|
||||
ofSetColor(ofColor::red);
|
||||
ofDrawRectangle(0, 100, pl * 50, 10);
|
||||
ofSetColor(ofColor::lightBlue);
|
||||
ofDrawRectangle(0, 120, pr * 50, 10);
|
||||
}else{
|
||||
ofSetColor(ofColor::green);
|
||||
ofDrawRectangle(0, 110, pb * 50, 10);
|
||||
ofSetColor(ofColor::yellow);
|
||||
ofDrawRectangle(0, 130, pt * 50, 10);
|
||||
}
|
||||
}
|
||||
ofPopMatrix();
|
||||
shader->begin();
|
||||
ofSetColor(ofFloatColor(1, 1, 1, 1));
|
||||
ofTranslate(-1 * pl * magic, -1 * pt * magic, 0);
|
||||
//msdf_atlas::unicode_t a = previous_c;
|
||||
//msdf_atlas::unicode_t b = c;
|
||||
//if(!firstLetter){
|
||||
//double advance;
|
||||
//cout << "this is being printed" << endl;
|
||||
//atlas->getFontGeometry();
|
||||
//cout << "this is maybeh being printed" << endl;
|
||||
//bool gotAdvance = atlas->getFontGeometry().getAdvance(advance, a, b);
|
||||
//cout << "this is being not printed" << endl;
|
||||
//if(gotAdvance){
|
||||
////ofTranslate(advance * magic, 0, 0);
|
||||
//}
|
||||
//}else{
|
||||
//firstLetter = false;
|
||||
//}
|
||||
atlasImage.drawSubsection(0, 0, w, h, x, y, w, h);
|
||||
shader->end();
|
||||
ofPopMatrix();
|
||||
ofPopStyle();
|
||||
ofTranslate(w, 0, 0);
|
||||
ofTranslate(pr * magic, 0, 0);
|
||||
previous_c = c;
|
||||
}
|
||||
ofPopMatrix();
|
||||
//atlasImage.draw(x, y);
|
||||
|
|
|
@ -34,7 +34,7 @@ class Layer {
|
|||
bool mirror_y = false;
|
||||
float mirror_y_distance = 0;
|
||||
float letterDelay = 0;
|
||||
string text = "toast";
|
||||
string text = "quickmonkeythedogASYAHELLO";
|
||||
};
|
||||
struct Settings {
|
||||
uint32_t maxBufferSize = 100;
|
||||
|
|
|
@ -7,7 +7,7 @@ namespace ofxVariableLab {
|
|||
void LayerComposition::setup(){
|
||||
ofxMsdfgen::AtlasSettings settings;
|
||||
//settings.characters = "ABCDEFGHIJKL";
|
||||
settings.scale = 64;
|
||||
settings.scale = 256;
|
||||
//string fontName = "RobotoFlex.ttf";
|
||||
//string fontPath = "data/fonts/" + fontName;
|
||||
//string fontPath = "data/celines-fonts/testing2VF.ttf";
|
||||
|
@ -40,7 +40,7 @@ void LayerComposition::update(){
|
|||
|
||||
void LayerComposition::draw() const {
|
||||
for(const auto & layer : layers){
|
||||
layer->draw();
|
||||
layer->draw(glm::vec3(0, 200, 0));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue