summaryrefslogtreecommitdiff
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
parentf50dd71c019a901c032ce87fc007a76198a02632 (diff)
object oriented stars+gui
l---------gistanalysis/bin/data/passades1
-rw-r--r--lasertext/config.make3
-rw-r--r--lasertext/src/ofApp.cpp69
-rw-r--r--lasertext/src/ofApp.h69
4 files changed, 65 insertions, 77 deletions
diff --git a/gistanalysis/bin/data/passades b/gistanalysis/bin/data/passades
deleted file mode 120000
index 24b0c06..0000000
--- a/gistanalysis/bin/data/passades
+++ /dev/null
@@ -1 +0,0 @@
-/Users/tim/Dropbox/Passades-Vol.3 (The Ninth Set)/ \ No newline at end of file
diff --git a/lasertext/config.make b/lasertext/config.make
index 76445c7..9e6452a 100644
--- a/lasertext/config.make
+++ b/lasertext/config.make
@@ -6,7 +6,8 @@
################################################################################
# OF ROOT
# The location of your root openFrameworks installation
-OF_ROOT = ../../openFrameworks
+
+# OF_ROOT = ../../openFrameworks
################################################################################
# OF_ROOT = ../../..
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()));
}
diff --git a/lasertext/src/ofApp.h b/lasertext/src/ofApp.h
index 621b729..052d565 100644
--- a/lasertext/src/ofApp.h
+++ b/lasertext/src/ofApp.h
@@ -37,23 +37,30 @@ public:
class starSystem{
public:
vector<star> stars;
- ofVec2f centre;
- float radius;
- float rate;
- float speed;
- float lifespan;
float agevar;
float last;
- starSystem(ofVec2f c=ofVec2f(0,0), float _rad=100,float r=0.5,float s=5.0,float l=5.0,float v=1.0){
- init(c,_rad,r,s,l,v);
+ ofxPanel gui;
+ ofParameter<float> x;
+ ofParameter<float> y;
+ ofParameter<float> rate;
+ ofParameter<float> radius;
+ ofParameter<float> speed;
+ ofParameter<float> lifespan;
+ ofParameter<bool> bScan;
+ starSystem(){
}
- void init(ofVec2f c, float _rad,float r,float s,float l,float v){
- centre=c;
- radius=_rad;
- rate=r;
- speed=s;
- lifespan=l;
+ void init(string name="",int _gx=5, int _gy=5, float _x=0, float _y=0, float _rad=100,float r=0.5,float s=5.0,float l=5.0,float v=1.0){
+
agevar=v;
+
+ gui.setup(name,"",_gx,_gy);
+ gui.add(x.set("x", _x, -2000.0f, 2000.0f));
+ gui.add(y.set("y", _y, -2000.0f, 2000.0f));
+ gui.add(rate.set("rate", r, 0.01f, 3.0f));
+ gui.add(radius.set("radius", _rad, 10.0f, 500.0f));
+ gui.add(speed.set("speed", s, 0.0f, 10.0f));
+ gui.add(lifespan.set("life", l, 3.0f, 10.0f));
+ gui.add(bScan.set("scan", true));
}
void update(){
float now=ofGetElapsedTimef();
@@ -96,17 +103,30 @@ public:
}
}
- vector<scannableColourPolyline> getPoints(){
+ vector<colourPolyline> getPoints(){
float now=ofGetElapsedTimef();
- vector<scannableColourPolyline> o;
- for(auto& s:stars){
+ vector<scannableColourPolyline> s;
+ for(auto& star:stars){
scannableColourPolyline l;
//ofLog()<<"get star";
- l.addVertex(centre.x+s.pos.x,centre.y+s.pos.y,ofColor(1.0f-((now-s.birthday)/s.lifespan)*128.0f));
- l.addVertex(centre.x+s.pos.x+1,centre.y+s.pos.y+1,ofColor(1.0f-((now-s.birthday)/s.lifespan)*128.0f));
- o.push_back(l);
+ l.addVertex(x+star.pos.x,y+star.pos.y,ofColor(1.0f-((now-star.birthday)/star.lifespan)*128.0f));
+ l.addVertex(x+star.pos.x+1,y+star.pos.y+1,ofColor(1.0f-((now-star.birthday)/star.lifespan)*128.0f));
+ s.push_back(l);
+ }
+
+ if (bScan){
+ std::sort(s.begin(),s.end());
}
- return o;
+
+ vector<colourPolyline> o;
+
+ int numstars=0;
+ for (auto& shape: s) {
+ shape.draw();
+ o.push_back((colourPolyline)shape);
+ }
+
+ return o;
}
};
@@ -141,15 +161,6 @@ class ofApp : public ofBaseApp{
string displaytext;
glyphbanner banner;
- ofxPanel starsgui;
- ofParameter<float> stars_x;
- ofParameter<float> stars_y;
- ofParameter<float> stars_rate;
- ofParameter<float> stars_radius;
- ofParameter<float> stars_speed;
- ofParameter<float> stars_life;
- ofParameter<bool> bScanStars;
-
ofxPanel textgui;
ofParameter<float> laser_scale;
ofParameter<float> laser_pos_x;