[ Video ]
[ About ]
The outer circles do not overlap.
[ 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 windowResized(int w, int h) {}; void dragEvent(ofDragInfo dragInfo) {}; void gotMessage(ofMessage msg) {}; float noise_seed; }; |
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 90 91 92 93 94 95 96 97 98 99 100 101 102 |
#include "ofApp.h" //-------------------------------------------------------------- void ofApp::setup() { ofSetFrameRate(60); ofSetWindowTitle("openframeworks"); ofBackground(239); this->noise_seed = ofRandom(1000); } //-------------------------------------------------------------- void ofApp::update() { if (ofGetFrameNum() % 60 < 45) { this->noise_seed += ofMap(ofGetFrameNum() % 60, 0, 45, 0.05, 0); } } //-------------------------------------------------------------- void ofApp::draw() { ofTranslate(ofGetWidth() * 0.5, ofGetHeight() * 0.5); for (int x = -230; x <= 230; x += 230) { for (int y = -230; y <= 230; y += 230) { ofPushMatrix(); ofTranslate(x, y); int base_radius = 30; { vector<glm::vec2> vertices; for (int deg = 0; deg < 360; deg += 5) { vertices.push_back(glm::vec2(base_radius * cos(deg * DEG_TO_RAD), base_radius * sin(deg * DEG_TO_RAD))); } ofFill(); ofSetColor(239); ofBeginShape(); ofVertices(vertices); ofEndShape(true); ofNoFill(); ofSetColor(39); ofBeginShape(); ofVertices(vertices); ofEndShape(true); } for (int deg = 0; deg < 360; deg += 10) { auto base_location = glm::vec2(base_radius * cos(deg * DEG_TO_RAD), base_radius * sin(deg * DEG_TO_RAD)); auto out_radius = ofMap(ofNoise(x + base_location.x, y + base_location.y, this->noise_seed), 0, 1, base_radius, base_radius * 3); auto out_location = glm::vec2(out_radius * cos(deg * DEG_TO_RAD), out_radius * sin(deg * DEG_TO_RAD)); ofDrawLine(base_location, out_location); auto small_radius = (out_radius * 2 * PI) / 360 * 10 * 0.5; ofPushMatrix(); ofTranslate(out_location); vector<glm::vec2> vertices; for (int d = 0; d < 360; d += 5) { vertices.push_back(glm::vec2(small_radius * cos(d * DEG_TO_RAD), small_radius * sin(d * DEG_TO_RAD))); } ofFill(); ofSetColor(239); ofBeginShape(); ofVertices(vertices); ofEndShape(true); ofNoFill(); ofSetColor(39); ofBeginShape(); ofVertices(vertices); ofEndShape(true); ofPopMatrix(); } ofPopMatrix(); } } } //-------------------------------------------------------------- int main() { ofSetupOpenGL(720, 720, OF_WINDOW); ofRunApp(new ofApp()); } |