[ 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 |
#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) {}; ofPoint make_rect_point(int len, int deg, int z = 0); 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 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
#include "ofApp.h" //-------------------------------------------------------------- void ofApp::setup() { ofSetFrameRate(60); ofBackground(39); ofSetWindowTitle("Insta"); ofEnableBlendMode(ofBlendMode::OF_BLENDMODE_ADD); ofSetRectMode(ofRectMode::OF_RECTMODE_CENTER); } //-------------------------------------------------------------- void ofApp::update() { ofSeedRandom(39); } //-------------------------------------------------------------- void ofApp::draw() { this->cam.begin(); ofTranslate(0, 0, -2048); int len = ofGetWidth() / 2; ofColor line_color; for (int i = 0; i < 32; i++) { int deg = ofRandom(360) + ofNoise(i * 0.1, ofGetFrameNum() * 0.005) * 360; int deg_end = deg + ofRandom(45, 225); int z = ((int)ofRandom(2048) + ofGetFrameNum() * 10) % 2048; line_color.setHsb(ofRandom(255), 239, 239); ofSetColor(line_color, ofMap(z, 0, 2048, 0, 128)); ofBeginShape(); for (; deg < deg_end; deg += 1) { ofVertex(make_rect_point(len, deg, z)); } ofEndShape(true); } this->cam.end(); } //-------------------------------------------------------------- ofPoint ofApp::make_rect_point(int len, int deg, int z) { deg += 45; int param = deg / 90; switch (param % 4) { case 0: return ofPoint(len, ofMap(deg % 90, 0, 89, -len, len), z); case 1: return ofPoint(ofMap(deg % 90, 0, 89, len, -len), len, z); case 2: return ofPoint(-len, ofMap(deg % 90, 0, 89, len, -len), z); case 3: return ofPoint(ofMap(deg % 90, 0, 89, -len, len), -len, z); } return ofPoint(); } //-------------------------------------------------------------- int main() { ofSetupOpenGL(720, 720, OF_WINDOW); ofRunApp(new ofApp()); } |