[ 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 |
#pragma once #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 windowResized(int w, int h) {}; void dragEvent(ofDragInfo dragInfo) {}; void gotMessage(ofMessage msg) {}; ofColor color_1, color_2; }; |
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 |
#include "ofApp.h" //-------------------------------------------------------------- void ofApp::setup() { ofSetFrameRate(60); ofSetWindowTitle("Insta"); this->color_1 = ofColor(239); this->color_2 = ofColor(139, 39, 39); ofBackground(this->color_1); ofSetLineWidth(5); ofEnableSmoothing(); } //-------------------------------------------------------------- void ofApp::update() { ofSeedRandom(39); } //-------------------------------------------------------------- void ofApp::draw() { int radius = 200; int x_step = 1; ofFill(); ofSetColor(this->color_2); ofBeginShape(); for (int deg = 0; deg < 360; deg++) { ofVertex(radius * cos(deg * DEG_TO_RAD) + ofGetWidth() / 2, radius * sin(deg * DEG_TO_RAD) + ofGetHeight() / 2); } ofEndShape(true); ofNoFill(); for (int i = 0; i < 10; i++) { vector<ofPoint> vertices; bool overlap = false; float r_1 = ofRandom(0.0003, 0.001); float r_2 = ofRandom(0.0005, 0.002); for (int x = 0; x < ofGetWidth(); x += x_step) { ofPoint point = ofPoint(x, ofMap(ofNoise(i, x * r_1, ofGetFrameNum() * r_2), 0, 1, -ofGetHeight() * 0.2, ofGetHeight() * 1.2)); if (point.distance(ofPoint(ofGetWidth() / 2, ofGetHeight() / 2)) < radius) { if (overlap) { vertices.push_back(point); } else { ofSetColor(this->color_2); ofBeginShape(); ofVertices(vertices); ofEndShape(); overlap = true; vertices.clear(); } } else { if (overlap) { ofSetColor(this->color_1); ofBeginShape(); ofVertices(vertices); ofEndShape(); overlap = false; vertices.clear(); } else { vertices.push_back(point); } } } overlap ? ofSetColor(this->color_1) : ofSetColor(this->color_2); ofBeginShape(); ofVertices(vertices); ofEndShape(); } } //-------------------------------------------------------------- int main() { ofSetupOpenGL(720, 720, OF_WINDOW); ofRunApp(new ofApp()); } |