[ Video ]
[ About ]
グラデーション・サークル。
Gradation circle.
[ 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) {}; vector<ofMesh> mesh_list; }; |
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 |
#include "ofApp.h" //-------------------------------------------------------------- void ofApp::setup() { ofSetFrameRate(60); ofSetWindowTitle("openframeworks"); ofBackground(239); ofSetColor(39); auto len = 30; ofColor in_color, out_color; for (auto radius = 150; radius < 300; radius += len * 2) { ofMesh mesh; for (auto deg = 0; deg < 360; deg += 1) { int out_radius = radius + len; auto in_location = glm::vec2(radius * cos(deg * DEG_TO_RAD), radius * sin(deg * DEG_TO_RAD)); auto out_location = glm::vec2(out_radius * cos(deg * DEG_TO_RAD), out_radius * sin(deg * DEG_TO_RAD)); mesh.addVertex(ofPoint(in_location)); mesh.addColor(ofColor()); mesh.addVertex(ofPoint(out_location)); mesh.addColor(ofColor()); } for (auto i = 0; i < mesh.getVertices().size(); i += 2) { auto index_0 = i; auto index_1 = (i + 1) % mesh.getVertices().size(); auto index_2 = (i + 2) % mesh.getVertices().size(); auto index_3 = (i + 3) % mesh.getVertices().size(); mesh.addIndex(index_0); mesh.addIndex(index_1); mesh.addIndex(index_2); mesh.addIndex(index_3); mesh.addIndex(index_1); mesh.addIndex(index_2); } this->mesh_list.push_back(mesh); } } //-------------------------------------------------------------- void ofApp::update() { ofColor color; for (auto& mesh : this->mesh_list) { for (auto i = 0; i < mesh.getVertices().size(); i += 1) { auto location = mesh.getVertices()[i]; color.setHsb(ofMap(ofNoise(location.x * 0.01, location.y * 0.01, ofGetFrameNum() * 0.005), 0, 1, 0, 255), 255, 255); mesh.setColor(i, color); } } } //-------------------------------------------------------------- void ofApp::draw() { ofTranslate(ofGetWidth() * 0.5, ofGetHeight() * 0.5); for (auto& mesh : this->mesh_list) { mesh.draw(); } } //-------------------------------------------------------------- int main() { ofSetupOpenGL(720, 720, OF_WINDOW); ofRunApp(new ofApp()); } |
[ Link ]
https://github.com/junkiyoshi/openframeworks20191014