[ Video ]
[ About ]
Instagramのアカウントへ最小の円以外を消すことはできますか?とコメントを頂いたのでやってみました。もともと、再帰の繰り返しだったので、もともとあったif文にelse句を追加するだけでOKでした。
[ 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 25 |
#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) {}; ofEasyCam cam; void drawCircle(int level, ofPoint point, float radius); }; |
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 |
#include "ofApp.h" //-------------------------------------------------------------- void ofApp::setup() { ofSetFrameRate(60); ofBackground(230); ofSetWindowTitle("Insta"); ofSetColor(39); //ofNoFill(); } //-------------------------------------------------------------- void ofApp::update() { } //-------------------------------------------------------------- void ofApp::draw() { this->drawCircle(2, ofPoint(ofGetWidth() / 4, ofGetHeight() / 4), ofGetWidth() / 4); this->drawCircle(3, ofPoint(ofGetWidth() / 4 * 3, ofGetHeight() / 4), ofGetWidth() / 4); this->drawCircle(4, ofPoint(ofGetWidth() / 4, ofGetHeight() / 4 * 3), ofGetWidth() / 4); this->drawCircle(5, ofPoint(ofGetWidth() / 4 * 3, ofGetHeight() / 4 * 3), ofGetWidth() / 4); } //-------------------------------------------------------------- void ofApp::drawCircle(int level, ofPoint point, float radius) { if (level > 0) { float deg = ofGetFrameNum() * (6 - level); ofPoint point_1 = ofPoint(point.x + (radius / 2) * cos(deg * DEG_TO_RAD), point.y + (radius / 2) * sin(deg * DEG_TO_RAD)); ofPoint point_2 = ofPoint(point.x - (radius / 2) * cos(deg * DEG_TO_RAD), point.y - (radius / 2) * sin(deg * DEG_TO_RAD)); this->drawCircle(level - 1, point_1, radius / 2); this->drawCircle(level - 1, point_2, radius / 2); } else { ofPushMatrix(); ofTranslate(point); ofBeginShape(); for (int deg = 0; deg <= 360; deg += 1) { float x = radius * cos(deg * DEG_TO_RAD); float y = radius * sin(deg * DEG_TO_RAD); ofVertex(x, y); } ofEndShape(); ofPopMatrix(); } } //-------------------------------------------------------------- int main() { ofSetupOpenGL(720, 720, OF_WINDOW); ofRunApp(new ofApp()); } |