[ Video ]
[ About ]
廻るD
Rotate D.
[ 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) {}; ofPoint make_point(int radius, int deg); }; |
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 |
#include "ofApp.h" //-------------------------------------------------------------- void ofApp::setup() { ofSetFrameRate(60); ofSetWindowTitle("openframeworks"); ofBackground(39); ofSetColor(239); ofSetLineWidth(1.5); ofNoFill(); } //-------------------------------------------------------------- void ofApp::update() { } //-------------------------------------------------------------- void ofApp::draw() { ofTranslate(ofGetWidth() * 0.4, ofGetHeight() * 0.5); for (int radius = 150; radius < 350; radius += 10) { int start_deg = ofGetFrameNum() + radius * 5; ofBeginShape(); for (int deg = start_deg; deg < start_deg + 180; deg++) { ofVertex(this->make_point(radius, deg)); } ofEndShape(); } } //-------------------------------------------------------------- ofPoint ofApp::make_point(int radius, int deg) { deg = deg % 360; if ((deg >= 0 && deg < 90) || (deg >= 270 && deg < 360)) { return ofPoint(radius * cos(deg * DEG_TO_RAD), radius * sin(deg * DEG_TO_RAD)); } else if (deg >= 90 && deg < 110) { return ofPoint(radius * cos(deg * DEG_TO_RAD), radius); } else if (deg >= 110 && deg < 250) { return ofPoint(radius * cos(110 * DEG_TO_RAD), ofMap(deg, 110, 250, radius, -radius)); } else if (deg >= 250 && deg < 270) { return ofPoint(radius * cos(deg * DEG_TO_RAD), -radius); } return ofPoint(); } //-------------------------------------------------------------- int main() { ofSetupOpenGL(720, 720, OF_WINDOW); ofRunApp(new ofApp()); } |