possibly better examples (untested)

This commit is contained in:
jrkb 2023-08-04 10:03:07 +02:00
parent c36483ab21
commit f4cb8bec03
3 changed files with 95 additions and 42 deletions

View file

@ -1,4 +1,5 @@
#include "ofApp.h"
#include "Atlas.h"
#include "conversion.h"
#include "import-font.h"
#include "ofAppRunner.h"
@ -12,11 +13,25 @@ void ofApp::setup(){
ofSetVerticalSync(false);
//string fontName = "RobotoFlex.ttf";
//string fontPath = "data/fonts/" + fontName;
string fontPath = "data/celines-fonts/testing2VF.ttf";
string fontPath = "data/celines-fonts/TonkaFlowers.ttf";
//string fontPath = "data/celines-fonts/Cottagecore.ttf";
ofxMsdfgen::AtlasSettings settings;
settings.characters = "ABCDEFGHIJKL";
settings.minimumScale = 256;
settings.scale = 256;
settings.maxInterpolationStepSize = 10;
settings.characters = "acdqrs"; //"abjkosy";
// fine acdhjopqrs
// // fucked befgiklmn
atlas.setup(fontPath, settings);
vector <ofxMsdfgen::FontVariation> fvs;
fvs.push_back({"Weight", 0.0});
fvs.push_back({"Weight", 400.0});
//for(int i = 0; i < 16; i++){
//float value = i * 25;
//fvs.push_back({"Weight", 0.0});
//}
atlas.addVariations(fvs);
atlas.generate(true, true);
atlasImage = atlas.getAtlasImage();
glyphGeometries = atlas.getGlyphGeometries();
#ifdef TARGET_EMSCRIPTEN
@ -50,7 +65,7 @@ void ofApp::draw(){
shader.begin();
shader.setUniformTexture("msdf", atlasImage.getTexture(), 0);
shader.setUniform4f("fontColor", ofFloatColor::white);
shader.setUniform4f("fontColor", ofFloatColor::red);
ofPushMatrix();
ofTranslate(40, 40, 0);
@ -62,7 +77,8 @@ void ofApp::draw(){
//unicode_t character = word[c];
//const ofxMsdfgen::GlyphGeometry & glyphGeometry = glyphGeometries[0];
int amount = 0;
float mouser = ofGetMousePressed() ? ofMap(ofGetMouseX(), 0, ofGetWidth(), 0.001, 1) : 1;
float mouser = ofGetMousePressed() ? ofMap(ofGetMouseX(), 0, ofGetWidth(), 0.001, 4) : 1;
shader.setUniform1f("pxRange", mouser);
for(int iz = 0; iz < 3; iz++){
tx = 0;
ty = 0;
@ -91,7 +107,9 @@ void ofApp::draw(){
ofDisableAlphaBlending();
ofDisableDepthTest();
cam.end();
ofClear(0, 0, 0, 255);
atlasImage.draw(0, 0, ofGetHeight(), ofGetHeight());
shader.end();
ofPushStyle();
ofSetColor(ofColor::purple);
@ -106,6 +124,10 @@ void ofApp::draw(){
void ofApp::keyPressed(int key){
if(key == 's'){
atlasImage.save("web_atlasImage.png");
}else{
//a
atlas.settings.characters = "" + (char)key;
atlas.generate();
}
}