summaryrefslogtreecommitdiff
path: root/lasertext/src/ofApp.cpp
diff options
context:
space:
mode:
authorTim Redfern <redfernt@gmail.com>2023-08-17 22:41:00 +0100
committerTim Redfern <redfernt@gmail.com>2023-08-17 22:41:00 +0100
commit6c6bb89f8b3bd00fa7fc693e8dedc65efd502c0b (patch)
tree3fd2eedf5e0b586bc9e5f38d66e6457ee6f2cf40 /lasertext/src/ofApp.cpp
parentf50dd71c019a901c032ce87fc007a76198a02632 (diff)
object oriented stars+gui
Diffstat (limited to 'lasertext/src/ofApp.cpp')
-rw-r--r--lasertext/src/ofApp.cpp69
1 files changed, 23 insertions, 46 deletions
diff --git a/lasertext/src/ofApp.cpp b/lasertext/src/ofApp.cpp
index b5fb1ae..e7341fa 100644
--- a/lasertext/src/ofApp.cpp
+++ b/lasertext/src/ofApp.cpp
@@ -3,6 +3,11 @@
/*
what do we want to store/control per letter?
+
+
+1. play back arbitrary text
+2. web server to submit text
+3. animate based on audio
*/
@@ -20,15 +25,7 @@ void ofApp::setup(){
banner.loadFont("fonts/EMSDecorousScript.svg"); // EMSPepita.svg"); //fonts.getPath(currentFont));
banner.init("Everything Is Going To Be Alright");
- starsgui.setup("stars","",5,450);
- starsgui.add(stars_x.set("x", 0.0f, -2000.0f, 2000.0f));
- starsgui.add(stars_y.set("y", 0.0f, -2000.0f, 2000.0f));
- starsgui.add(stars_rate.set("y", 1.0f, 0.01f, 3.0f));
- starsgui.add(stars_radius.set("radius", 100.0f, 10.0f, 500.0f));
- starsgui.add(stars_speed.set("speed", 5.0f, 0.0f, 10.0f));
- starsgui.add(stars_life.set("life", 4.0f, 3.0f, 10.0f));
- starsgui.add(bScanStars.set("scan", true));
-
+ stars.init("stars",5,450);
textgui.setup("text","",5,650);
textgui.add(laser_scale.set("scale", 1.0f, 0.5f, 3.0f));
@@ -82,14 +79,14 @@ void ofApp::setup(){
laser_blank_num=XML.getValue("laser:blankpoints",8);
laser_max_angle=XML.getValue("laser:maxangle",15.0f);
- stars_x=XML.getValue("stars:X",0.0f);
- stars_y=XML.getValue("stars:Y",0.0f);
- stars_rate=XML.getValue("stars:rate",1.0f);
- stars_radius=XML.getValue("stars:radius",100.0f);
- stars_speed=XML.getValue("stars:speed",5.0f);
- stars_life=XML.getValue("stars:life",4.0f);
+ stars.x=XML.getValue("stars:X",0.0f);
+ stars.y=XML.getValue("stars:Y",0.0f);
+ stars.rate=XML.getValue("stars:rate",1.0f);
+ stars.radius=XML.getValue("stars:radius",100.0f);
+ stars.speed=XML.getValue("stars:speed",5.0f);
+ stars.lifespan=XML.getValue("stars:life",4.0f);
- stars.init(ofVec2f(2000.0f,2000.0f),100.0f,1.0,5.0,4.0,1.0);
+ //stars.init(ofVec2f(2000.0f,2000.0f),100.0f,1.0,5.0,4.0,1.0);
}
@@ -125,12 +122,12 @@ void ofApp::save_settings(){
XML.setValue("laser:blankpoints",laser_blank_num);
XML.setValue("laser:maxangle",laser_max_angle);
- XML.setValue("stars:X",stars_x);
- XML.setValue("stars:Y",stars_y);
- XML.setValue("stars:rate",stars_rate);
- XML.setValue("stars:radius",stars_radius);
- XML.setValue("stars:speed",stars_speed);
- XML.setValue("stars:life",stars_life);
+ XML.setValue("stars:X",stars.x);
+ XML.setValue("stars:Y",stars.y);
+ XML.setValue("stars:rate",stars.rate);
+ XML.setValue("stars:radius",stars.radius);
+ XML.setValue("stars:speed",stars.speed);
+ XML.setValue("stars:life",stars.lifespan);
XML.saveFile("settings.xml");
cout << "settings.xml saved!" <<std::endl;
@@ -147,13 +144,6 @@ void ofApp::update(){
laser.set_intensity(laser_intensity);
-
- stars.centre=ofVec2f(stars_x,stars_y);
- stars.rate=stars_rate;
- stars.radius=stars_radius;
- stars.speed=stars_speed;
- stars.lifespan=stars_life;;
-
stars.update();
}
@@ -164,7 +154,7 @@ void ofApp::draw(){
textgui.draw();
lasergui.draw();
- starsgui.draw();
+ stars.gui.draw();
lineTransformer::drawWarpFrame(warpframe);
@@ -218,28 +208,15 @@ void ofApp::draw(){
ofSetColor(255,255,255);
- vector<scannableColourPolyline> starshapes=stars.getPoints();
-
- if (bScanStars){
- std::sort(starshapes.begin(),starshapes.end());
- }
-
- vector<colourPolyline> laserstars;
-
- int numstars=0;
- for (auto& s: starshapes) {
- numstars+=s.size();
- s.draw();
- laserstars.push_back((colourPolyline)s);
- }
+ vector<colourPolyline> laserstars=stars.getPoints();
num+=laser.draw(laserstars);
if (num>0){
- ofSetWindowTitle(ofToString(ofGetFrameRate(), 2)+" fps laser points: "+ofToString(num)+", stars: "+ofToString(numstars));
+ ofSetWindowTitle(ofToString(ofGetFrameRate(), 2)+" fps laser points: "+ofToString(num)+", stars: "+ofToString(laserstars.size()));
}
else {
- ofSetWindowTitle(ofToString(ofGetFrameRate(), 2)+" fps laser power off, stars: "+ofToString(numstars));
+ ofSetWindowTitle(ofToString(ofGetFrameRate(), 2)+" fps laser power off, stars: "+ofToString(laserstars.size()));
}