worldSize playaround
This commit is contained in:
parent
962e52502b
commit
5456033ccf
1 changed files with 33 additions and 19 deletions
|
@ -1,6 +1,7 @@
|
||||||
#include "GPUFontAtlasLayerCombo.h"
|
#include "GPUFontAtlasLayerCombo.h"
|
||||||
#include "Utils.h"
|
#include "Utils.h"
|
||||||
#include "ofColor.h"
|
#include "ofColor.h"
|
||||||
|
#include "ofEvents.h"
|
||||||
|
|
||||||
namespace ofxVariableLab {
|
namespace ofxVariableLab {
|
||||||
|
|
||||||
|
@ -46,20 +47,20 @@ void GPUFontAtlasLayerCombo::setup(const ComboIdentifier & identifier){
|
||||||
cout << "Render type " << r->getType() << endl;
|
cout << "Render type " << r->getType() << endl;
|
||||||
}
|
}
|
||||||
void GPUFontAtlasLayerCombo::update(){
|
void GPUFontAtlasLayerCombo::update(){
|
||||||
float animationSpeed = ofMap(sin(ofGetElapsedTimef() * 0.01), -1, 1, 0.0, 2);
|
//float animationSpeed = ofMap(sin(ofGetElapsedTimef() * 0.01), -1, 1, 0.0, 2);
|
||||||
float threshold = 5.0;
|
//float threshold = 5.0;
|
||||||
for(int i = 0; i < fontVariationAxes.size(); i++){
|
//for(int i = 0; i < fontVariationAxes.size(); i++){
|
||||||
ofxGPUFont::Font::FontVariationAxis & axis = fontVariationAxes[i];
|
//ofxGPUFont::Font::FontVariationAxis & axis = fontVariationAxes[i];
|
||||||
ofxGPUFont::Font::FontVariationAxisParameters & axisParams = fontVariationAxesParameters[i];
|
//ofxGPUFont::Font::FontVariationAxisParameters & axisParams = fontVariationAxesParameters[i];
|
||||||
double newValue = ofMap(sin(ofGetElapsedTimef() * animationSpeed),
|
//double newValue = ofMap(sin(ofGetElapsedTimef() * animationSpeed),
|
||||||
-1, 1,
|
//-1, 1,
|
||||||
axisParams.minValue, axisParams.maxValue);
|
//axisParams.minValue, axisParams.maxValue);
|
||||||
if(abs(newValue - axis.value) > threshold){
|
//if(abs(newValue - axis.value) > threshold){
|
||||||
font->setFontVariationAxis(library, axis.name, newValue);
|
//font->setFontVariationAxis(library, axis.name, newValue);
|
||||||
axis.value = newValue;
|
//axis.value = newValue;
|
||||||
font->prepareGlyphsForText(mainText, true);
|
//font->prepareGlyphsForText(mainText, true);
|
||||||
}
|
//}
|
||||||
}
|
//}
|
||||||
}
|
}
|
||||||
void GPUFontAtlasLayerCombo::careForChild(shared_ptr <Layer> layer){
|
void GPUFontAtlasLayerCombo::careForChild(shared_ptr <Layer> layer){
|
||||||
}
|
}
|
||||||
|
@ -77,10 +78,21 @@ void GPUFontAtlasLayerCombo::draw(){
|
||||||
|
|
||||||
int width = ofGetWidth();
|
int width = ofGetWidth();
|
||||||
int height = ofGetHeight();
|
int height = ofGetHeight();
|
||||||
|
glm::vec2 mouse = glm::vec2(ofGetMouseX(), ofGetMouseY());
|
||||||
|
|
||||||
|
float targetFontSize = ofGetFrameNum() % 100 < 50 ? 42 : 420;
|
||||||
|
|
||||||
|
float worldSize = targetFontSize / (float)width;
|
||||||
|
|
||||||
|
font->setWorldSize(worldSize);
|
||||||
|
|
||||||
|
float width_unit = 1;
|
||||||
|
float height_unit = (float)height / width;
|
||||||
|
|
||||||
//ofClear(125, 255, 125, 255);
|
//ofClear(125, 255, 125, 255);
|
||||||
|
|
||||||
glm::mat4 projection = transform.getProjectionMatrix((float)width / height);
|
//glm::mat4 projection = transform.getProjectionMatrix((float)width / height);
|
||||||
|
glm::mat4 projection = transform.getOrthoProjectionMatrix(width_unit, height_unit);
|
||||||
glm::mat4 view = transform.getViewMatrix();
|
glm::mat4 view = transform.getViewMatrix();
|
||||||
glm::mat4 model = glm::mat4(1.0f);
|
glm::mat4 model = glm::mat4(1.0f);
|
||||||
|
|
||||||
|
@ -132,19 +144,21 @@ void GPUFontAtlasLayerCombo::draw(){
|
||||||
glUniform1i(location, enableControlPointsVisualization);
|
glUniform1i(location, enableControlPointsVisualization);
|
||||||
|
|
||||||
|
|
||||||
|
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);
|
cx = 0.5f * (bb.minX + bb.maxX);
|
||||||
cy = 0.5f * (bb.minY + bb.maxY);
|
cy = 0.5f * (bb.minY + bb.maxY);
|
||||||
//ofRectangle rectangle(0, 0, width, height);
|
//ofRectangle rectangle(0, 0, width, height);
|
||||||
//ofDrawRectangle(rectangle);
|
//ofDrawRectangle(rectangle);
|
||||||
font->draw(-cx, -cy, 0, mainText);
|
font->draw(mx, my, 0, mainText, vFlip == V_FLIP_ON);
|
||||||
glUseProgram(currentProgram);
|
glUseProgram(currentProgram);
|
||||||
}
|
}
|
||||||
|
|
||||||
glDisable(GL_BLEND);
|
glDisable(GL_BLEND);
|
||||||
|
|
||||||
ofDrawBitmapStringHighlight(
|
//ofDrawBitmapStringHighlight(
|
||||||
"this is where your font could be"
|
//(ofToString("and we know:") + ofToString("everything"))
|
||||||
, -cx, -cy, ofFloatColor::pink, ofFloatColor::black);
|
//, 100 + mouse.x, mouse.y, ofFloatColor::pink, ofFloatColor::black);
|
||||||
|
|
||||||
ofDrawBitmapStringHighlight(
|
ofDrawBitmapStringHighlight(
|
||||||
"fps: " + ofToString(ofGetFrameRate()) + "\n"
|
"fps: " + ofToString(ofGetFrameRate()) + "\n"
|
||||||
|
|
Loading…
Reference in a new issue