[ Video ]
[ About ]
円の円周に円を描写しています。それぞれの小さい方の円の場所は、属している大きい円の座標からNoise関数で計算されいるので、座標で近い値を指します。
[ Source ]
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
#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) {}; void draw_circle(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(239); ofSetWindowTitle("Insta"); ofSetColor(39); ofNoFill(); } //-------------------------------------------------------------- void ofApp::update() { } //-------------------------------------------------------------- void ofApp::draw() { int size = 60; for (int x = size / 2; x < ofGetWidth() + size / 2; x += size) { for (int y = size / 2; y < ofGetHeight() + size / 2; y += size) { ofPoint point = ofPoint(x, y); float radius = (size * 0.5) * 0.8; ofNoFill(); this->draw_circle(point, radius); float mini_radius = radius * 0.25; float mini_deg = ofNoise(x * 0.001, y * 0.001 - ofGetFrameNum() * 0.01) * 720; ofPoint mini_point = point + ofPoint(radius * cos(mini_deg * DEG_TO_RAD), radius * sin(mini_deg * DEG_TO_RAD)); ofFill(); this->draw_circle(mini_point, mini_radius); } } } //-------------------------------------------------------------- void ofApp::draw_circle(ofPoint point, float radius) { ofPushMatrix(); ofTranslate(point); ofBeginShape(); for (int deg = 0; deg < 360; deg += 1) { ofVertex(radius * cos(deg * DEG_TO_RAD), radius * sin(deg * DEG_TO_RAD)); } ofEndShape(); ofPopMatrix(); } //-------------------------------------------------------------- int main() { ofSetupOpenGL(720, 720, OF_WINDOW); ofRunApp(new ofApp()); } |