diff options
| author | Tim Redfern <tim@getdrop.com> | 2022-08-16 23:24:37 +0100 |
|---|---|---|
| committer | Tim Redfern <tim@getdrop.com> | 2022-08-16 23:24:37 +0100 |
| commit | 08968b9557456b3b9d3566d4dca1b9190bd8fba1 (patch) | |
| tree | c8fb87123adb512ffe3786be0b982dc81ea6fae4 /lasertext | |
| parent | 1fe5dceef2df8cb7a67e0760507be418bee754b8 (diff) | |
use a palette
Diffstat (limited to 'lasertext')
| -rw-r--r-- | lasertext/src/ofApp.cpp | 3 | ||||
| -rw-r--r-- | lasertext/src/ofApp.h | 50 |
2 files changed, 45 insertions, 8 deletions
diff --git a/lasertext/src/ofApp.cpp b/lasertext/src/ofApp.cpp index 96b56ab..5e6865e 100644 --- a/lasertext/src/ofApp.cpp +++ b/lasertext/src/ofApp.cpp @@ -35,6 +35,7 @@ void ofApp::setup(){ else{ cout << "unable to load settings.xml"<<std::endl; } + } //-------------------------------------------------------------- void ofApp::update(){ @@ -99,7 +100,7 @@ void ofApp::keyPressed(ofKeyEventArgs &args){ //-------------------------------------------------------------- void ofApp::keyReleased(int key){ if (key>=' '&&key<='~'){ - banner.addGlyph(key,ofColor::fromHsb(ofRandom(255.0),225,255)); + banner.addGlyph(key); } else if (key==OF_KEY_BACKSPACE||key==OF_KEY_DEL) { //DEL banner.removeGlyph(); 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; + }; |
