[ Video ]
[ About ]
Day 26 Bed.
ノイズ周期で起きたり・寝たりを繰り返す、いらすとやさんのイラスト
Image by www.irasutoya.com
[ 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 |
#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) {}; ofImage bed_image1; ofImage bed_image2; }; |
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 |
#include "ofApp.h" //-------------------------------------------------------------- void ofApp::setup() { ofSetFrameRate(60); ofSetWindowTitle("openFrameworks"); ofBackground(239); this->bed_image1.loadImage("images/bed1.png"); this->bed_image2.loadImage("images/bed2.png"); } //-------------------------------------------------------------- void ofApp::update() { } //-------------------------------------------------------------- void ofApp::draw() { int size = 120; for (int x = 0; x < ofGetWidth(); x += size) { float noise_height = ofNoise(x * 0.03, ofGetFrameNum() * 0.03) * ofGetHeight(); for (int y = 0; y < ofGetHeight(); y += size) { noise_height > y ? this->bed_image1.draw(x, y, size, size) : this->bed_image2.draw(x, y, size, size); } } } //-------------------------------------------------------------- int main() { ofSetupOpenGL(720, 720, OF_WINDOW); ofRunApp(new ofApp()); } |