[ Video ]
[ About ]
ノイズの渦
Swirl of noise.
[ 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 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
#include "ofApp.h" //-------------------------------------------------------------- void ofApp::setup() { ofSetFrameRate(60); ofSetWindowTitle("openFrameworks"); ofBackground(239); ofSetColor(39); } //-------------------------------------------------------------- void ofApp::update() { ofSeedRandom(39); } //-------------------------------------------------------------- void ofApp::draw() { int radius_min = 15; int radius_max = 100; float deg_width = 45; int span = 240; for (int y = span * 0.5; y < ofGetHeight(); y += span) { for (int x = span * 0.5; x < ofGetWidth(); x += span) { ofPushMatrix(); ofTranslate(x, y); vector<glm::vec2> vertices_top; vector<glm::vec2> vertices_right; vector<glm::vec2> vertices_bottom; vector<glm::vec2> vertices_left; float random_seed = ofRandom(720); for (int radius = radius_min; radius <= radius_max; radius += 1) { float deg_center = ofMap(ofNoise(random_seed, radius * 0.005 + ofGetFrameNum() * 0.01), 0, 1, 0, 360); vertices_right.push_back(glm::vec2(radius * cos((deg_center + deg_width * 0.5) * DEG_TO_RAD), radius * sin((deg_center + deg_width * 0.5) * DEG_TO_RAD))); vertices_left.push_back(glm::vec2(radius * cos((deg_center - deg_width * 0.5) * DEG_TO_RAD), radius * sin((deg_center - deg_width * 0.5) * DEG_TO_RAD))); if (radius == radius_min) { for (int deg = deg_center - deg_width * 0.5; deg <= deg_center + deg_width * 0.5; deg += 1) { vertices_bottom.push_back(glm::vec2(radius_min * cos(deg * DEG_TO_RAD), radius_min * sin(deg * DEG_TO_RAD))); } } if (radius == radius_max) { for (int deg = deg_center - deg_width * 0.5; deg <= deg_center + deg_width * 0.5; deg += 1) { vertices_top.push_back(glm::vec2(radius_max * cos(deg * DEG_TO_RAD), radius_max * sin(deg * DEG_TO_RAD))); } } } std::reverse(vertices_right.begin(), vertices_right.end()); std::reverse(vertices_bottom.begin(), vertices_bottom.end()); for (int i = 0; i < 4; i++) { ofRotate(90); ofBeginShape(); ofVertices(vertices_top); ofVertices(vertices_right); ofVertices(vertices_bottom); ofVertices(vertices_left); ofEndShape(); } ofPopMatrix(); } } } //-------------------------------------------------------------- int main() { ofSetupOpenGL(720, 720, OF_WINDOW); ofRunApp(new ofApp()); } |