[ Video ]
[ About ]
フレーム数を引数としたNoise関数によって円が回転しています。円の回転量は半径と反比例するようにしてあるので、小さな円は大きく動き、大きな円は鈍くなっています。
[ 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" 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) {}; // Make Member ofEasyCam cam; // Make Method void draw_twist_circle(ofPoint point, int radius_base, int radius_max, int radius_span); }; |
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 |
#include "ofApp.h" //-------------------------------------------------------------- void ofApp::setup() { ofSetFrameRate(60); ofBackground(239); ofSetWindowTitle("Insta"); ofNoFill(); ofSetColor(39); ofSetLineWidth(2); ofEnableDepthTest(); } //-------------------------------------------------------------- void ofApp::update() { ofSeedRandom(3939); } //-------------------------------------------------------------- void ofApp::draw() { this->cam.begin(); for (int x = -1; x < 2; x++) { for (int y = -1; y < 2; y++) { this->draw_twist_circle(ofPoint(x * 230, y * 230), 20, 100, 10); } } this->cam.end(); } //-------------------------------------------------------------- void ofApp::draw_twist_circle(ofPoint point, int radius_base, int radius_max, int radius_span) { float noise_z = ofMap(ofNoise((ofRandom(1000) + ofGetFrameNum()) * 0.01), 0, 1, -180, 180); float noise_deg_x = ofMap(ofNoise((ofRandom(1000) + ofGetFrameNum()) * 0.01), 0, 1, -180, 180); float noise_deg_y = ofMap(ofNoise((ofRandom(1000) + ofGetFrameNum()) * 0.01), 0, 1, -180, 180); for (int radius = radius_base; radius <= radius_max; radius += radius_span) { ofPushMatrix(); ofTranslate(point + ofPoint(0, 0, noise_z * ofMap(radius, radius_base, radius_max, 1, 0))); if (radius < radius_max * 0.65) { ofRotateX(noise_deg_x * ofMap(radius, radius_base, radius_max * 0.65, 3, 0.8)); ofRotateY(noise_deg_y * ofMap(radius, radius_base, radius_max * 0.65, 3, 0.8)); } else { ofRotateX(noise_deg_x * ofMap(radius, radius_max * 0.65, radius_max, 0.8, 0)); ofRotateY(noise_deg_y * ofMap(radius, radius_max * 0.65, radius_max, 0.8, 0)); } ofBeginShape(); for (int deg = 0; deg <= 360; deg++) { ofVertex(radius * cos(deg * DEG_TO_RAD), radius * sin(deg * DEG_TO_RAD)); } ofEndShape(true); ofPopMatrix(); } } //-------------------------------------------------------------- int main() { ofSetupOpenGL(720, 720, OF_WINDOW); ofRunApp(new ofApp()); } |