[ Video ]
[ About ]
Day 29 Supermarket
スーパーマーケットの棚をイメージして
Imagination from bis shelf of supermarket.
[ 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) {}; void draw_shelf(int y, int height, int span); 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 |
#include "ofApp.h" //-------------------------------------------------------------- void ofApp::setup() { ofSetFrameRate(60); ofSetWindowTitle("openFrameworks"); ofBackground(239); ofSetColor(39); ofEnableDepthTest(); ofSetLineWidth(2); } //-------------------------------------------------------------- void ofApp::update() { ofSeedRandom(39); } //-------------------------------------------------------------- void ofApp::draw() { this->cam.begin(); ofRotateY(90); for (int y = -ofGetWidth() * 0.5; y < ofGetHeight() * 0.5; y += 144) { this->draw_shelf(y, 120, 30); } this->cam.end(); } //-------------------------------------------------------------- void ofApp::draw_shelf(int y, int height, int span) { for (int z = -300; z <= 300; z += 600) { ofSetColor(39); ofDrawLine(glm::vec3(-ofGetWidth(), y, z), glm::vec3(ofGetWidth() * 2, y, z)); for (int x = -ofGetWidth(); x < ofGetWidth() * 2; x += span) { int y_max = y + ofNoise(ofRandom(39), ofGetFrameNum() * 0.005) * height; for (int tmp_y = y; tmp_y <= y_max; tmp_y += span) { if (x > ofGetWidth()) { ofSetColor(39, ofMap(x, ofGetWidth(), ofGetWidth() * 2, 255, 0)); } ofDrawRectangle(glm::vec3(x, tmp_y, z), span * 0.8, span * 0.8); } } } } //-------------------------------------------------------------- int main() { ofSetupOpenGL(720, 720, OF_WINDOW); ofRunApp(new ofApp()); } |