From 3f24a2f8f7f05b9200fb0f5341a3fc1139ee7748 Mon Sep 17 00:00:00 2001 From: Tim Redfern Date: Tue, 16 Aug 2022 00:36:53 +0100 Subject: add gui --- lasertext/addons.make | 2 ++ lasertext/src/ofApp.cpp | 35 +++++++++++++++++++++++++++++++---- lasertext/src/ofApp.h | 38 +++++++++++++++++++++++++++++++++++--- 3 files changed, 68 insertions(+), 7 deletions(-) diff --git a/lasertext/addons.make b/lasertext/addons.make index e557404..aa9be02 100644 --- a/lasertext/addons.make +++ b/lasertext/addons.make @@ -1,2 +1,4 @@ ofxSvg +ofxGui +ofxXmlSettings ofxHelios \ No newline at end of file diff --git a/lasertext/src/ofApp.cpp b/lasertext/src/ofApp.cpp index adb393f..2974056 100644 --- a/lasertext/src/ofApp.cpp +++ b/lasertext/src/ofApp.cpp @@ -22,10 +22,33 @@ void ofApp::setup(){ laser.set_pts(MAX_POINTS); laser.set_intensity(LASER_INTENSITY); + + lasergui.setup("laser","",5,700); + lasergui.add(laser_power.set("power", true)); + lasergui.add(laser_intensity.set("intensity", 30, 0, 255)); + lasergui.add(laser_points.set("points", 30000, 0, 40000)); + lasergui.add(laser_subdivide.set("subdivide", 15, 1, 100)); + lasergui.add(laser_blank_num.set("blank points", 8, 0, 32)); + lasergui.add(laser_max_angle.set("max angle", 15.0f, 1.0f, 90.0f)); + + if( XML.loadFile("settings.xml") ){ + cout << "settings.xml loaded!" < shapes = banner.getOutlines(0.06f+(0.02f*sin(ofGetElapsedTimef()*.1f))); + lasergui.draw(); + + vector shapes = banner.getOutlines(0.08f); //+(0.02f*sin(ofGetElapsedTimef()*.1f))); + + int num = 0; - int num = laser.draw(shapes); + if (laser_power) num=laser.draw(shapes); //banner.draw(); @@ -49,7 +76,7 @@ void ofApp::draw(){ ofSetWindowTitle(ofToString(ofGetFrameRate(), 2)+" fps laser points: "+ofToString(num)); } else { - ofSetWindowTitle(ofToString(ofGetFrameRate(), 2)+" fps laser error "); + ofSetWindowTitle(ofToString(ofGetFrameRate(), 2)+" fps laser power off "); } } diff --git a/lasertext/src/ofApp.h b/lasertext/src/ofApp.h index a15d918..3fcde84 100644 --- a/lasertext/src/ofApp.h +++ b/lasertext/src/ofApp.h @@ -2,6 +2,8 @@ #include "ofMain.h" #include "ofxSvg.h" +#include "ofxGui.h" +#include "ofxXmlSettings.h" #include "ofxHelios.h" #include "colourPolyline.h" @@ -83,6 +85,13 @@ public: } return _w+max((float)(words.size()-1)*enspace,0.0f); } + int glyphCount(){ + int c=0; + for (auto& w:words){ + c+=w.glyphs.size(); + } + return c; + } string text(){ string s; for (auto& w:words) { @@ -170,13 +179,25 @@ public: void clear(){words.clear();} void update(float period=1.0f){ float t=ofGetElapsedTimef()/period; - int theword=int(t)%words.size(); - float segment=t-int(t); + int theword=0; + float segment=0.0f; + if (false){ //1 word per second + theword=int(t)%words.size(); + segment=t-int(t); + } + else { //proportional to #of letters + int theletter=int(t)%glyphCount(); + theword=0; + while((theletter-=words[theword].glyphs.size())>0){ + theword++; + } + segment=(((float)theletter+words[theword].glyphs.size()+t-int(t))/words[theword].glyphs.size()); + } //calculate params for word/letter anim for (int i=0;i laser_power; + ofParameter laser_intensity; + ofParameter laser_points; + ofParameter laser_subdivide; + ofParameter laser_blank_num; + ofParameter laser_max_angle; + + ofxXmlSettings XML; }; -- cgit v1.2.3