[ Video ]
[ About ]
オリンピックがテレビで沢山流れていたので、昨日のソースをいじってオリンピックカラーに改造しました。(それよりもバレンタインデーでしたね…)
ちなみに、オリンピックは生中継をほとんど見ずに、朝のニュースで結果だけ楽しむ派です。
[ 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 | #pragma once #include "ofMain.h" #include "ofFbo.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 windowResized(int w, int h) {}; 	void dragEvent(ofDragInfo dragInfo) {}; 	void gotMessage(ofMessage msg) {}; 	ofFbo fbo; 	int size; 	vector<ofColor> colors; 	vector<vector<float>> values; }; | 
| 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 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 | #include "ofApp.h" //-------------------------------------------------------------- void ofApp::setup() { 	ofSetFrameRate(30); 	ofBackground(255); 	ofSetWindowTitle("Insta"); 	this->size = 5; 	this->colors.push_back(ofColor(0, 117, 201)); 	this->colors.push_back(ofColor(255, 164, 0)); 	this->colors.push_back(ofColor(38, 39, 42)); 	this->colors.push_back(ofColor(0, 149, 58)); 	this->colors.push_back(ofColor(236, 0, 68)); 	this->fbo.allocate(ofGetWidth(), ofGetHeight()); } //-------------------------------------------------------------- void ofApp::update() { 	this->values.clear(); 	float x_count = ofGetWidth() / this->size; 	float y_count = ofGetHeight() / this->size; 	for (int y = 0; y < y_count; y++) { 		vector<float> tmp_values; 		for (int x = 0; x < x_count; x++) { 			if (y == 0) { 				float value = ofMap(ofNoise(x * 0.05, ofGetFrameNum() * 0.05), 0, 1, this->size, 0); 				tmp_values.push_back(value); 			} 			else { 				float value = 0; 				int count = 0; 				for (int tmp_x = x - 1; tmp_x <= x + 1; tmp_x++) { 					if (tmp_x >= 0 && tmp_x < x_count) { 						value += this->values[y - 1][tmp_x]; 						count++; 					} 				} 				if (y >= 2) { 					value += this->values[y - 2][x]; 					count++; 				} 				float average = value / count + ofMap(ofNoise(x * 0.03, y * 0.1 - ofGetFrameNum() * 0.5), 0, 1, -3, 3); 				tmp_values.push_back(average); 			} 		} 		this->values.push_back(tmp_values); 	} 	this->fbo.begin(); 	ofClear(0); 	int color_index = 0; 	int span = ofGetWidth() / this->colors.size(); 	for (int x = 0; x < ofGetWidth(); x += span) { 		ofSetColor(this->colors[color_index]); 		color_index++; 		ofDrawRectangle(ofVec2f(x, 0), x + span, ofGetHeight()); 	} 	ofSetColor(255); 	for (int y = 0; y < this->values.size(); y++) { 		for (int x = 0; x < this->values[y].size(); x++) { 			ofDrawCircle(ofVec2f(x * this->size + this->size / 2, ofGetHeight() - (y * this->size + this->size / 2)), this->size - this->values[y][x]); 		} 	} 	this->fbo.end(); } //-------------------------------------------------------------- void ofApp::draw() { 	ofSetColor(255); 	this->fbo.draw(0, 0); } //======================================================================== int main() { 	ofSetupOpenGL(1280, 720, OF_WINDOW); 	ofRunApp(new ofApp()); } |