summaryrefslogtreecommitdiff
path: root/lasertext/src/ofApp.h
diff options
context:
space:
mode:
Diffstat (limited to 'lasertext/src/ofApp.h')
-rw-r--r--lasertext/src/ofApp.h50
1 files changed, 43 insertions, 7 deletions
diff --git a/lasertext/src/ofApp.h b/lasertext/src/ofApp.h
index 5ca1895..d87f37f 100644
--- a/lasertext/src/ofApp.h
+++ b/lasertext/src/ofApp.h
@@ -52,6 +52,28 @@ class glyphbanner{
float lastUpdateTime;
float playhead;
float enspace;
+ vector<ofColor> palette;
+ struct {
+ vector<ofColor> balanced={
+ ofColor::fromHex(0xE27D60),
+ ofColor::fromHex(0x085DCB),
+ ofColor::fromHex(0xE8A87C),
+ ofColor::fromHex(0xC38D9E),
+ ofColor::fromHex(0x41B3A3)
+ };
+ vector<ofColor> uneasy={
+ ofColor::fromHex(0x2154B9),
+ ofColor::fromHex(0xC45A62),
+ ofColor::fromHex(0x95A28A),
+ ofColor::fromHex(0x98546D),
+ ofColor::fromHex(0xE9DADA),
+ ofColor::fromHex(0x9FF3E9),
+ ofColor::fromHex(0xD07B37),
+ ofColor::fromHex(0x741710),
+ ofColor::fromHex(0x102ADC),
+ ofColor::fromHex(0x9FA1AC)
+ };
+ }palettes;
vector<string> split(string s) {
size_t pos_start = 0, pos_end;
string token;
@@ -67,7 +89,9 @@ class glyphbanner{
return res;
}
public:
- glyphbanner(){};
+ glyphbanner(){
+ palette=palettes.uneasy;
+ };
void init(string message){
createWords(message);
lastUpdateTime=ofGetElapsedTimef();
@@ -113,13 +137,17 @@ public:
}
}
- void createWords(string message){
+ void createWords(string message,bool usePalette=true){
clear();
vector<string> m=split(message);
for (auto& word: m){
glyphWord w;
for (auto& c: word){
- w.glyphs.push_back(getGlyph(c,ofColor::fromHsb(ofRandom(255.0),225,255)));
+ w.glyphs.push_back(getGlyph(c,
+ usePalette?
+ palette[ofRandom(palette.size())]:
+ ofColor::fromHsb(ofRandom(255.0),225,255)
+ ));
}
words.push_back(w);
}
@@ -163,10 +191,14 @@ public:
if (shape.size()) shapes.push_back(shape);
return glyph(c,charWidth,shapes,col);
}
- void addGlyph(char g,ofColor c){
+ void addGlyph(char g,bool usePalette=true){
if (g==' ') words.push_back(glyphWord());
else {
- words[words.size()-1].glyphs.push_back(getGlyph(g,c));
+ words[words.size()-1].glyphs.push_back(getGlyph(g,
+ usePalette?
+ palette[ofRandom(palette.size())]:
+ ofColor::fromHsb(ofRandom(255.0),225,255)
+ ));
}
}
void removeGlyph(){
@@ -179,7 +211,7 @@ public:
}
}
void clear(){words.clear();}
- void update(float speed=1.0f){
+ void update(float speed=1.0f,float usePalette=true){
float delta=ofGetElapsedTimef()-lastUpdateTime;
lastUpdateTime=ofGetElapsedTimef();
@@ -204,7 +236,10 @@ public:
words[i].amount=(i==theword?sin(segment*3.1415):0);
for (auto& g:words[i].glyphs){
if (ofRandom(100)<speed) {
- g.randomiseColour();
+ g.colour=
+ usePalette?
+ palette[ofRandom(palette.size())]:
+ ofColor::fromHsb(ofRandom(255.0),225,255);
}
}
}
@@ -273,4 +308,5 @@ class ofApp : public ofBaseApp{
ofParameter<float> laser_max_angle;
ofxXmlSettings XML;
+
};