[ Video ]
[ About ]
画面の左端と右端を結ぶ線を作り、線より上部には白い丸だけ、下部には黒い丸だけを描写しています。結ばれた線上にかかっている円は切れて見えるようになっているので実際には描写していないのですが、線が見えてくる気がします。
[ Source ]
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
#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 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 |
#include "ofApp.h" //-------------------------------------------------------------- void ofApp::setup() { ofSetFrameRate(60); ofBackground(139); ofSetWindowTitle("Insta"); } //-------------------------------------------------------------- void ofApp::update() { } //-------------------------------------------------------------- void ofApp::draw() { ofPoint start = ofPoint(0, ofNoise(11, ofGetFrameNum() * 0.01) * ofGetHeight()); ofPoint end = ofPoint(ofGetWidth(), ofNoise(3, ofGetFrameNum() * 0.01) * ofGetHeight()); ofPoint distance = end - start; float radius = 72; bool flag = true; for (int circle_x = radius; circle_x < ofGetWidth() + radius; circle_x += radius * 2) { for (int circle_y = radius; circle_y < ofGetHeight() + radius; circle_y += radius * 2) { flag ? ofSetColor(39) : ofSetColor(239); ofBeginShape(); for (int deg = 0; deg < 360; deg++) { float x = radius * cos(deg * DEG_TO_RAD) + circle_x; float y = radius * sin(deg * DEG_TO_RAD) + circle_y; ofPoint point = start + (distance / ofGetWidth()) * x; if (y > point.y) { flag ? ofVertex(x, y) : ofVertex(point); } else { flag ? ofVertex(point) : ofVertex(x, y); } } ofEndShape(true); flag = !flag; } } } //-------------------------------------------------------------- int main() { ofSetupOpenGL(720, 720, OF_WINDOW); ofRunApp(new ofApp()); } |