[ Video ]
[ About ]
やもりのシルエットをGECKOという文字で埋めました。Noiseで文字を変化、文字と色はリンクしています。
[ Source ]
| 
					 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26  | 
						#include "ofMain.h" class ofApp : public ofBaseApp { public: 	void setup(); 	void update(); 	void draw(); 	void keyPressed(int key) {}; 	void keyReleased(int key) {}; 	void mouseMoved(int x, int y) {}; 	void mouseDragged(int x, int y, int button) {}; 	void mousePressed(int x, int y, int button) {}; 	void mouseReleased(int x, int y, int button) {}; 	void mouseEntered(int x, int y) {}; 	void mouseExited(int x, int y) {}; 	void windowResized(int w, int h) {}; 	void dragEvent(ofDragInfo dragInfo) {}; 	void gotMessage(ofMessage msg) {}; 	ofImage image; 	ofPixels pix; 	ofTrueTypeFont font; };  | 
					
| 
					 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51  | 
						#include "ofApp.h" //-------------------------------------------------------------- void ofApp::setup() { 	ofSetFrameRate(60); 	ofBackground(39); 	ofSetWindowTitle("Insta"); 	this->font.loadFont("fonts/Kazesawa-Bold.ttf", 15); 	this->image.load("images/gecko.png"); 	this->pix = this->image.getPixelsRef(); } //-------------------------------------------------------------- void ofApp::update() { } //-------------------------------------------------------------- void ofApp::draw() { 	ofColor word_color; 	vector<string> word = { "G", "E", "C", "K", "O" }; 	ofTranslate((ofGetWidth() - this->image.getWidth()) * 0.5, (ofGetHeight() - this->image.getHeight()) * 0.5); 	for (int x = 0; x < this->image.getWidth(); x += this->font.getSize()) { 		for (int y = 0; y < this->image.getHeight(); y += this->font.getSize()) { 			ofColor pix_color = this->pix.getColor(x, y); 			if (pix_color != ofColor(0)) { 				continue; 			} 			int word_index = ofMap(ofNoise(x * 0.008, y * 0.008 + ofGetFrameNum() * 0.03), 0, 1, 0, word.size()); 			word_color.setHsb(ofMap(word_index, 0, word.size(), 0, 239), 200, 255); 			ofSetColor(word_color); 			this->font.drawString(word[word_index], x, y); 		} 	} } //-------------------------------------------------------------- int main() { 	ofSetupOpenGL(720, 720, OF_WINDOW); 	ofRunApp(new ofApp()); }  |