summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Redfern <tim@getdrop.com>2022-08-15 21:04:21 +0100
committerTim Redfern <tim@getdrop.com>2022-08-15 21:04:21 +0100
commite471ae5b7df7e5d7d0190b354846fa24b0ad9d61 (patch)
treea250b5a56b772035a896b2d1b9183d2940fc5506
parent895389c009da308c4a1f01d0f17d8304ea12c915 (diff)
init banner with string
-rw-r--r--lasertext/src/ofApp.cpp2
-rw-r--r--lasertext/src/ofApp.h29
2 files changed, 28 insertions, 3 deletions
diff --git a/lasertext/src/ofApp.cpp b/lasertext/src/ofApp.cpp
index b6f4061..8e5a4cd 100644
--- a/lasertext/src/ofApp.cpp
+++ b/lasertext/src/ofApp.cpp
@@ -18,7 +18,7 @@ void ofApp::setup(){
currentFont=0;
banner.loadFont("fonts/EMSPepita.svg"); //fonts.getPath(currentFont));
- banner.init({"Everything","Is","Going","To","Be","Alright"});
+ banner.init("Everything Is Going To Be Alright");
laser.set_pts(MAX_POINTS);
laser.set_intensity(LASER_INTENSITY);
diff --git a/lasertext/src/ofApp.h b/lasertext/src/ofApp.h
index e8c7da9..46f6bbc 100644
--- a/lasertext/src/ofApp.h
+++ b/lasertext/src/ofApp.h
@@ -6,6 +6,8 @@
#include "ofxHelios.h"
#include "colourPolyline.h"
+
+
class glyph{
public:
glyph(char c,float w,vector<ofPolyline> lines){
@@ -30,20 +32,39 @@ public:
ofColor colour;
};
+//how to deal with words
+
class glyphbanner{
ofXml SVGFont;
vector<glyph> glyphs;
vector<colourPolyline> outlines;
ofVec2f centre;
+ float lastUpdateTime;
+ vector<string> split(string s) {
+ size_t pos_start = 0, pos_end;
+ string token;
+ vector<string> res;
+
+ while ((pos_end = s.find (" ", pos_start)) != string::npos) {
+ token = s.substr (pos_start, pos_end - pos_start);
+ pos_start = pos_end + 1;
+ res.push_back (token);
+ }
+
+ res.push_back (s.substr (pos_start));
+ return res;
+ }
public:
glyphbanner(){};
- void init(vector<string> message){
- for (auto& word: message){
+ void init(string message){
+ vector<string> m=split(message);
+ for (auto& word: m){
for (auto& c: word){
addGlyph(c,ofColor::fromHsb(ofRandom(255.0),225,255));
}
addGlyph(' ');
}
+ lastUpdateTime=ofGetElapsedTimef();
}
int length(){return glyphs.size();}
float width(){
@@ -121,6 +142,10 @@ public:
}
ofPopMatrix();
}
+ void update(){
+ //calculate params for word/letter anim
+
+ }
vector<colourPolyline>& getOutlines(){
outlines.clear();
float p=(-width())/2;