[ Video ]
[ About ]
昨日のやつに色を付けて、ぐるぐる回してみました。均等に円が配置されるのも確認が出来る!
[ 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 |
#include "ofApp.h" //-------------------------------------------------------------- void ofApp::setup() { ofSetFrameRate(60); ofBackground(239); ofSetWindowTitle("Insta"); } //-------------------------------------------------------------- void ofApp::update() { } //-------------------------------------------------------------- void ofApp::draw() { ofTranslate(ofGetWidth() / 2, ofGetHeight() / 2); float radius = 50; float small_radius = 0; int deg_span = 8; for (int i = 0; radius < 330; i++) { if (small_radius == 0) { ofPoint p1 = ofPoint(radius * cos(0), radius * sin(0)); ofPoint p2 = ofPoint(radius * cos(deg_span * DEG_TO_RAD), radius * sin(deg_span * DEG_TO_RAD)); small_radius = p1.distance(p2) * 0.5; } float noise_value = ofNoise(i * 0.05 + ofGetFrameNum() * 0.01); ofPushMatrix(); ofRotate(noise_value * 360); for (int deg = 0; deg < 360; deg += deg_span) { ofColor circle_color; circle_color.setHsb(ofMap(deg, 0, 360, 0, 255), 239, 239); ofSetColor(circle_color, 139 + 39); ofPoint point = ofPoint(radius * cos(deg * DEG_TO_RAD), radius * sin(deg * DEG_TO_RAD)); ofDrawCircle(point, small_radius); } float next_small_radius = 0; float tmp_radius = radius; while (radius < tmp_radius + small_radius + next_small_radius) { ofPoint p1 = ofPoint(radius * cos(0), radius * sin(0)); ofPoint p2 = ofPoint(radius * cos(deg_span * DEG_TO_RAD), radius * sin(deg_span * DEG_TO_RAD)); next_small_radius = p1.distance(p2) * 0.5; radius += 0.01; } small_radius = next_small_radius; ofPopMatrix(); } } //======================================================================== int main() { ofSetupOpenGL(720, 720, OF_WINDOW); ofRunApp(new ofApp()); } |