[ Video ]
[ About ]
並べて見比べるNoiseによる曲線
Compare noisy curves.
[ Source ]
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
#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) {}; }; |
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 |
#include "ofApp.h" //-------------------------------------------------------------- void ofApp::setup() { ofSetFrameRate(60); ofSetWindowTitle("openframeworks"); ofBackground(39); ofSetColor(239); ofSetLineWidth(3); } //-------------------------------------------------------------- void ofApp::update() { ofSeedRandom(39); } //-------------------------------------------------------------- void ofApp::draw() { int length = 30; int x_span = 90; int y_span = 90; for (int x = 0; x < ofGetWidth(); x += x_span) { for (int y = 0; y < ofGetHeight(); y += y_span) { float x_seed = ofRandom(100); float y_seed = ofRandom(100); ofPoint point; ofPoint prev_point = ofPoint(); for (int l = 0; l < length; l++) { point = ofPoint(ofMap(ofNoise(x_seed, (ofGetFrameNum() + l) * 0.015), 0, 1, x, x + x_span), ofMap(ofNoise(y_seed, (ofGetFrameNum() + l) * 0.015), 0, 1, y, y + y_span)); if (l != 0) { ofDrawLine(prev_point, point); } prev_point = point; } ofDrawCircle(point, 3); } } } //-------------------------------------------------------------- int main() { ofGLWindowSettings settings; settings.setGLVersion(3, 2); settings.setSize(720, 720); ofCreateWindow(settings); ofRunApp(new ofApp()); } |