fontSize randomly animated with multiple pseudolayers

This commit is contained in:
jrkb 2023-04-12 17:37:45 +02:00
parent 358452f98e
commit 7016b0629f

View file

@ -49,6 +49,13 @@ void GPUFontAtlasLayerCombo::setup(const ComboIdentifier & identifier){
cout << "Render type " << r->getType() << endl;
}
void GPUFontAtlasLayerCombo::update(){
//#ifndef TARGET_OPENGLES
//if(ofGetFrameNum() % 10 == 0){
//shaderCatalog->requestUpdate("font");
//}else if(ofGetFrameNum() % 10 == 5){
//shaderCatalog->update();
//}
//#endif
float animationSpeed = ofMap(sin(ofGetElapsedTimef() * 0.01), -1, 1, 0.1, 2);
float threshold = 1.0;
for(int i = 0; i < fontVariationAxes.size(); i++){
@ -84,10 +91,6 @@ void GPUFontAtlasLayerCombo::draw(){
float targetFontSize = 128;
float worldSize = targetFontSize / (float)width;
font->setWorldSize(targetFontSize);
float width_unit = 1;
float height_unit = (float)height / width;
@ -97,6 +100,7 @@ void GPUFontAtlasLayerCombo::draw(){
glm::mat4 projection = transform.getOrthoProjectionMatrix(width,
height,
Transform::TOP_LEFT);
//Transform::CENTERED);
glm::mat4 view = transform.getViewMatrix();
glm::mat4 model = glm::mat4(1.0f);
@ -150,18 +154,20 @@ void GPUFontAtlasLayerCombo::draw(){
glUniform1i(location, enableControlPointsVisualization);
//mouse.x = 0;
//mouse.y = 0;
float mx = ofMap(mouse.x, 0, width, -0.5 * width_unit, 0.5 * width_unit);
float my = ofMap(mouse.y, 0, height, -0.5 * height_unit, 0.5 * height_unit);
cx = 0.5f * (bb.minX + bb.maxX);
cy = 0.5f * (bb.minY + bb.maxY);
//ofRectangle rectangle(0, 0, width, height);
//ofDrawRectangle(rectangle);
font->draw(mouse.x, mouse.y - (200 * sin(ofGetElapsedTimef() * 0.25)), 0, "what", vFlip == V_FLIP_ON);
font->draw(mouse.x, mouse.y - (200 * sin(ofGetElapsedTimef() * 0.25)), 0, "what", vFlip == V_FLIP_ON, 128.0f);
location = glGetUniformLocation(fontShaderProgram, "color");
glUniform4f(location, 0.0f, 1.0f, 0.0f, 0.5f);
font->draw(mouse.x, mouse.y, 0, "ever", vFlip == V_FLIP_ON);
font->draw(mouse.x, mouse.y, 0, "ever", vFlip == V_FLIP_ON, 64.0f);
glUniform4f(location, 0.0f, 0.0f, 1.0f, 0.5f);
font->draw(mouse.x, mouse.y + (200 * sin(ofGetElapsedTimef() * 0.25)), 0, "verraw", vFlip == V_FLIP_ON);
font->draw(mouse.x, mouse.y + (200 * sin(ofGetElapsedTimef() * 0.25)), 0, "verraw", vFlip == V_FLIP_ON, 256.0f);
glUseProgram(currentProgram);
}