[ Video ]
[ About ]
独楽回しeddy(@EKey2210)さんの投稿をマネしてみました。ofNoiseを使って変化している角度を30で区切ってあみだくじみたいにしました。
Inspire from @EKey2210(Twitter) post.
円運動の軌跡が作り出すトンネル#openframeworks pic.twitter.com/FR2UOeWu12
— 独楽回しeddy (@EKey2210) 2018年12月1日
[ 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 |
#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 mouseEntered(int x, int y) {}; void mouseExited(int x, int y) {}; void windowResized(int w, int h) {}; void dragEvent(ofDragInfo dragInfo) {}; void gotMessage(ofMessage msg) {}; ofEasyCam cam; }; |
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 |
#include "ofApp.h" //-------------------------------------------------------------- void ofApp::setup() { ofSetFrameRate(60); ofSetWindowTitle("openframeworks"); ofBackground(239); ofSetColor(39); ofEnableDepthTest(); ofSetLineWidth(3); } //-------------------------------------------------------------- void ofApp::update() { ofSeedRandom(39); } //-------------------------------------------------------------- void ofApp::draw() { this->cam.begin(); ofRotateY(180); int radius = 150; for (int i = 0; i < 8; i++) { float noise_param_1 = ofRandom(360); float noise_param_2 = ofRandom(360); glm::vec3 prev = glm::vec3(); for (int len = 0; len < 200; len += 1) { int deg = noise_param_1 + ofNoise(noise_param_2, (ofGetFrameNum() + len) * 0.005) * 360; deg = (deg / 30) * 30; glm::vec3 location = glm::vec3(radius * cos(deg * DEG_TO_RAD), radius * sin(deg * DEG_TO_RAD), len * 3); if (len != 0) { ofDrawLine(location, prev); } prev = location; } ofDrawSphere(prev, 3); } this->cam.end(); } //-------------------------------------------------------------- int main() { ofSetupOpenGL(720, 720, OF_WINDOW); ofRunApp(new ofApp()); } |