[ Video ]
[ About ]
BoxをX, Y, Z方向に敷き詰めて大きなBox集合体を構成しています。それぞれのBoxは座標情報とフレーム数を引数としたNoise関数の値で、大きさを変えており、法則性のようなものが垣間見えます。
[ Source ]
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
#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) {}; ofEasyCam cam; }; |
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 |
#include "ofApp.h" //-------------------------------------------------------------- void ofApp::setup() { ofSetFrameRate(60); ofBackground(239); ofSetWindowTitle("Insta"); ofEnableDepthTest(); } //-------------------------------------------------------------- void ofApp::update() { ofSeedRandom(39); } //-------------------------------------------------------------- void ofApp::draw() { this->cam.begin(); ofRotateY(ofGetFrameNum() * 0.25); int aggregation_size = 720; int box_size = 72; ofColor box_color; for (int x = -aggregation_size / 2; x <= aggregation_size / 2; x += box_size) { for (int y = -aggregation_size / 2; y <= aggregation_size / 2; y += box_size) { for (int z = -aggregation_size / 2; z <= aggregation_size / 2; z += box_size) { float noise_value = ofNoise(x * 0.004, y * 0.004, z * 0.004, ofGetFrameNum() * 0.005); noise_value = noise_value > 0.5 ? 1 : noise_value; box_color.setHsb(ofRandom(255), 225, 225); ofSetColor(box_color); ofDrawBox(ofPoint(x, y, z), box_size * noise_value); } } } this->cam.end(); } //-------------------------------------------------------------- int main() { ofSetupOpenGL(720, 720, OF_WINDOW); ofRunApp(new ofApp()); } |