[ Video ]
[ About ]
中央を円形にくり抜かれた四角の中の、円形が大きくなったり小さくなったり。
[ 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 26 27 |
#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) {} // Make Member ofEasyCam cam; // Make Method void draw_rect_and_circle(ofPoint point, int rect_len); }; |
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 |
#include "ofApp.h" //-------------------------------------------------------------- void ofApp::setup() { ofSetFrameRate(60); ofBackground(39, 39, 239); ofSetWindowTitle("Insta"); } //-------------------------------------------------------------- void ofApp::update() { ofSeedRandom(39); } //-------------------------------------------------------------- void ofApp::draw() { this->cam.begin(); int rect_len = 120; for (int x = -ofGetWidth() / 2 + rect_len / 2; x <= ofGetWidth() / 2 - rect_len / 2; x += rect_len) { for (int y = -ofGetHeight() / 2 + rect_len / 2; y <= ofGetHeight() / 2 - rect_len / 2; y += rect_len) { this->draw_rect_and_circle(ofPoint(x, y), rect_len); } } this->cam.end(); } //-------------------------------------------------------------- void ofApp::draw_rect_and_circle(ofPoint point, int rect_len) { ofPushMatrix(); ofTranslate(point); int radius = rect_len * 0.45; ofBeginShape(); ofVertex(-rect_len / 2, -rect_len / 2); ofVertex(rect_len / 2, -rect_len / 2); ofVertex(rect_len / 2, rect_len / 2); ofVertex(-rect_len / 2, rect_len / 2); ofNextContour(); for (int deg = 0; deg < 360; deg += 1) { ofVertex(radius * cos(deg * DEG_TO_RAD), radius * sin(deg * DEG_TO_RAD)); } ofEndShape(true); radius *= ofMap(ofNoise(point.x * 0.001, point.y * 0.001, ofGetFrameNum() * 0.01), 0, 1, 0.4, 1.2); ofBeginShape(); for (int deg = 0; deg < 360; deg += 1) { ofVertex(radius * cos(deg * DEG_TO_RAD), radius * sin(deg * DEG_TO_RAD)); } ofEndShape(true); ofPopMatrix(); } //-------------------------------------------------------------- int main() { ofSetupOpenGL(720, 720, OF_WINDOW); ofRunApp(new ofApp()); } |