summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Redfern <tim@getdrop.com>2022-08-16 00:36:53 +0100
committerTim Redfern <tim@getdrop.com>2022-08-16 00:36:53 +0100
commit3f24a2f8f7f05b9200fb0f5341a3fc1139ee7748 (patch)
treecf2e448ae5539bd1c6eb00ace937be6c5f199f0a
parent1fd61e1304cba349b4c1233919c862ae22b2ecff (diff)
add gui
-rw-r--r--lasertext/addons.make2
-rw-r--r--lasertext/src/ofApp.cpp35
-rw-r--r--lasertext/src/ofApp.h38
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!" <<std::endl;
+
+ }
+ else{
+ cout << "unable to load settings.xml"<<std::endl;
+ }
}
//--------------------------------------------------------------
void ofApp::update(){
- banner.update(10.0f);
+ banner.update(1.0f);
+
+ laser.set_pts(laser_points);
+ laser.set_subdivide(laser_subdivide);
+ laser.set_blanknum(laser_blank_num);
+ laser.set_maxangle(laser_max_angle);
+
+ laser.set_intensity(laser_intensity);
}
//--------------------------------------------------------------
@@ -33,9 +56,13 @@ void ofApp::draw(){
ofBackground(0,0,0);
ofSetColor(255,255,255);
- vector<colourPolyline> shapes = banner.getOutlines(0.06f+(0.02f*sin(ofGetElapsedTimef()*.1f)));
+ lasergui.draw();
+
+ vector<colourPolyline> 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<words.size();i++){
words[i].amount=(i==theword?sin(segment*3.1415):0);
for (auto& g:words[i].glyphs){
- if (ofRandom(period)<0.1) {
+ if (ofRandom(period)<0.01) {
g.randomiseColour();
}
}
@@ -231,4 +252,15 @@ class ofApp : public ofBaseApp{
string displaytext;
glyphbanner banner;
+ //======= laser gui
+
+ ofxPanel lasergui;
+ ofParameter<bool> laser_power;
+ ofParameter<int> laser_intensity;
+ ofParameter<int> laser_points;
+ ofParameter<int> laser_subdivide;
+ ofParameter<int> laser_blank_num;
+ ofParameter<float> laser_max_angle;
+
+ ofxXmlSettings XML;
};