[ Video ]
[ About ]
円をつなぐ線を書く。
凄く昔の落書きのリメイク。
Draw a line connecting the circles.
A remake of a very old doodle.
[ 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 54 55 56 57 58 59 60 61 62 |
#include "ofApp.h" //-------------------------------------------------------------- void ofApp::setup() { ofSetFrameRate(60); ofSetWindowTitle("openframeworks"); ofBackground(239); ofSetColor(39); } //-------------------------------------------------------------- void ofApp::update() { } //-------------------------------------------------------------- void ofApp::draw() { ofTranslate(ofGetWidth() * 0.5, ofGetHeight() * 0.5); int radius = 80; int location_radius = 230; int deg_span = 60; for (int deg = 0; deg < 360; deg += 10) { int tmp_deg = deg + ofGetFrameNum() * 0.5; vector<glm::vec2> vertices; for (int location_deg = 0; location_deg < 360; location_deg += deg_span) { auto base_location = glm::vec2(location_radius * cos(location_deg * DEG_TO_RAD), location_radius * sin(location_deg * DEG_TO_RAD)); auto location = glm::vec2(radius * cos(tmp_deg * DEG_TO_RAD), radius * sin(tmp_deg * DEG_TO_RAD)); vertices.push_back(base_location + location); tmp_deg += 120; } ofColor color = ofColor(); color.setHsb(ofMap(deg, 0, 360, 0, 255), 255, 230); ofSetColor(color); ofNoFill(); ofBeginShape(); ofVertices(vertices); ofEndShape(true); ofFill(); for (auto vertex : vertices) { ofDrawCircle(vertex, 3.5); } } } //-------------------------------------------------------------- int main() { ofSetupOpenGL(720, 720, OF_WINDOW); ofRunApp(new ofApp()); } |