[ Video ]
[ About ]
角度3度ごとに線を引いています。線の長さはNoise関数で生成した値を元に変化させているので、それぞれの部位ごとに滑らかに変化していきます。
何故か周期的に線の長さが揃って0に近くなるのですが、プログラミングでそのような機構は入れたつもりはなかったので、想定外の動きになります。
ofNoiseに与えているdegの値が大きすぎるせい??
[ 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 | #include "ofApp.h" //-------------------------------------------------------------- void ofApp::setup() { 	ofSetFrameRate(60); 	ofBackground(32); 	ofSetWindowTitle("Insta"); 	ofSetLineWidth(3); } //-------------------------------------------------------------- void ofApp::update() { } //-------------------------------------------------------------- void ofApp::draw() { 	ofTranslate(ofGetWidth() / 2, ofGetHeight() / 2); 	for (float radius = 50; radius <= 250; radius += 100) { 		for (float deg = 0; deg < 360; deg += 3) { 			float noise_value = ofNoise(deg - ofGetFrameNum() * 0.005) + 0.5; 			ofPoint point_1(radius * cos(deg * DEG_TO_RAD), radius * sin(deg * DEG_TO_RAD)); 			ofPoint point_2(radius * noise_value * cos(deg * DEG_TO_RAD), radius * noise_value * sin(deg * DEG_TO_RAD)); 			ofColor line_color; 			line_color.setHsb(deg / 360 * 255, 200, 200); 			ofSetColor(line_color); 			ofDrawLine(point_1, point_2); 		} 	} } //======================================================================== int main() { 	ofSetupOpenGL(720, 720, OF_WINDOW); 	ofRunApp(new ofApp()); } |