[ Video ]
[ About ]
壊れた円形
Broken circle.
[ 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) {}; void draw_shape(vector<glm::vec2>& param1, vector<glm::vec2>& param2); }; |
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 |
#include "ofApp.h" //-------------------------------------------------------------- void ofApp::setup() { ofSetFrameRate(60); ofSetWindowTitle("openframeworks"); ofBackground(239); ofSetColor(39); ofSetLineWidth(2); ofSetCircleResolution(60); } //-------------------------------------------------------------- void ofApp::update() { ofSeedRandom(39); } //-------------------------------------------------------------- void ofApp::draw() { ofTranslate(ofGetWidth() * 0.5, ofGetHeight() * 0.5); auto len = 25; vector<glm::vec2> outer, inner; for (int radius = 50; radius <= 300; radius += 50) { ofNoFill(); ofDrawCircle(glm::vec2(), radius); auto out_radius = radius + len * 0.5; auto in_radius = radius - len * 0.5; for (int deg = 0; deg <= 360; deg++) { auto noise_source = glm::vec2(radius * cos(deg * DEG_TO_RAD), radius * sin(deg * DEG_TO_RAD)); auto noise_value = ofNoise(noise_source.x * 0.005, noise_source.y * 0.005, ofGetFrameNum() * 0.005); if (noise_value < 0.55) { outer.push_back(glm::vec2(out_radius * cos(deg * DEG_TO_RAD), out_radius * sin(deg * DEG_TO_RAD))); inner.push_back(glm::vec2(in_radius * cos(deg * DEG_TO_RAD), in_radius * sin(deg * DEG_TO_RAD))); } else { this->draw_shape(outer, inner); } } this->draw_shape(outer, inner); } } //-------------------------------------------------------------- void ofApp::draw_shape(vector<glm::vec2>& param1, vector<glm::vec2>& param2) { if (param1.size() > 0 && param2.size() > 0) { std::reverse(param2.begin(), param2.end()); ofFill(); ofBeginShape(); ofVertices(param1); ofVertices(param2); ofEndShape(true); } param1.clear(); param2.clear(); } //-------------------------------------------------------------- int main() { ofSetupOpenGL(720, 720, OF_WINDOW); ofRunApp(new ofApp()); } |