[ Video ]
[ About ]
ベジェ曲線の円を重ねる。
Overlap the circles of the Bezier curve.
[ Source ]
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
#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) {}; }; |
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("openFrameworks"); ofBackground(0); ofSetLineWidth(1.5); ofEnableBlendMode(ofBlendMode::OF_BLENDMODE_ADD); } //-------------------------------------------------------------- void ofApp::update() { ofSeedRandom(39); } //-------------------------------------------------------------- void ofApp::draw() { int radius = 25; float handle_len = radius; int number_of_location = 4; int deg_span = 360 / number_of_location; vector<ofColor> color_list = {ofColor(255, 60, 60), ofColor(60, 255, 60), ofColor(60, 60, 255) }; for (int x = 120; x <= ofGetWidth() - 120; x += 80) { for (int y = 120; y <= ofGetHeight() - 120; y += 80) { ofPushMatrix(); ofTranslate(x, y); for (int i = 0; i < 3; i++) { auto noise_seed = glm::vec2(ofRandom(1000), ofRandom(1000)); vector<glm::vec2> location_list; vector<float> deg_list; for (int deg = 0; deg < 360; deg += deg_span) { location_list.push_back(glm::vec2(radius * cos(deg * DEG_TO_RAD), radius * sin(deg * DEG_TO_RAD))); deg_list.push_back(deg + 90); } for (int k = 0; k < location_list.size(); k++) { deg_list[k] += ofMap(ofNoise(noise_seed.x + location_list[k].x, noise_seed.y + location_list[k].y, ofGetFrameNum() * 0.01), 0, 1, -90, 90); } ofNoFill(); ofSetColor(color_list[i]); ofBeginShape(); for (int i = 0; i < location_list.size(); i++) { int n = (i + 1) % location_list.size(); ofVertex(location_list[i]); ofBezierVertex( location_list[i] + glm::vec2(handle_len * cos(deg_list[i] * DEG_TO_RAD), handle_len * sin(deg_list[i] * DEG_TO_RAD)), location_list[n] + glm::vec2(handle_len * cos((deg_list[n] + 180) * DEG_TO_RAD), handle_len * sin((deg_list[n] + 180) * DEG_TO_RAD)), location_list[n]); } ofEndShape(); ofFill(); ofSetColor(color_list[i] * 0.8); ofBeginShape(); for (int i = 0; i < location_list.size(); i++) { int n = (i + 1) % location_list.size(); ofVertex(location_list[i]); ofBezierVertex( location_list[i] + glm::vec2(handle_len * cos(deg_list[i] * DEG_TO_RAD), handle_len * sin(deg_list[i] * DEG_TO_RAD)), location_list[n] + glm::vec2(handle_len * cos((deg_list[n] + 180) * DEG_TO_RAD), handle_len * sin((deg_list[n] + 180) * DEG_TO_RAD)), location_list[n]); } ofEndShape(); } ofPopMatrix(); } } } //-------------------------------------------------------------- int main() { ofSetupOpenGL(720, 720, OF_WINDOW); ofRunApp(new ofApp()); } |
[ Link ]
GitHub is 500 Error.