From 08968b9557456b3b9d3566d4dca1b9190bd8fba1 Mon Sep 17 00:00:00 2001 From: Tim Redfern Date: Tue, 16 Aug 2022 23:24:37 +0100 Subject: use a palette --- lasertext/src/ofApp.cpp | 3 ++- lasertext/src/ofApp.h | 50 ++++++++++++++++++++++++++++++++++++++++++------- 2 files changed, 45 insertions(+), 8 deletions(-) (limited to 'lasertext') 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"<=' '&&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 palette; + struct { + vector balanced={ + ofColor::fromHex(0xE27D60), + ofColor::fromHex(0x085DCB), + ofColor::fromHex(0xE8A87C), + ofColor::fromHex(0xC38D9E), + ofColor::fromHex(0x41B3A3) + }; + vector 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 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 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) laser_max_angle; ofxXmlSettings XML; + }; -- cgit v1.2.3