[ Video ]
[ About ]
雨の夜。
Rainy night.
[ 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) {}; ofFbo fbo; void draw_tree(ofPoint point, float deg, int len, int depth); }; |
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 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
#include "ofApp.h" //-------------------------------------------------------------- void ofApp::setup() { ofSetFrameRate(24); ofBackground(0); ofSetWindowTitle("openFrameworks"); ofSetCircleResolution(72); this->fbo.allocate(ofGetWidth(), ofGetHeight() / 2); } //-------------------------------------------------------------- void ofApp::update() { ofSeedRandom(39); this->fbo.begin(); ofClear(0); // Draw Sun To Fbo ofPushMatrix(); ofTranslate(this->fbo.getWidth() / 3, this->fbo.getHeight() / 5 * 2); ofSetColor(255, 255, 0); ofDrawCircle(glm::vec3(), 100); ofPopMatrix(); // Draw Rain ofSetColor(255); for (int i = 0; i < 50; i++) { int x = ofRandom(ofGetWidth()); int y = (int)(ofRandom(this->fbo.getHeight()) + ofGetFrameNum() * ofRandom(10, 30)) % (int)this->fbo.getHeight(); ofDrawLine(x, y, x, y + ofRandom(10, 30)); } this->fbo.end(); } //-------------------------------------------------------------- void ofApp::draw() { ofTranslate(ofGetWidth() / 2, ofGetHeight() / 2); // Draw Fbo ofSetColor(255, 255); this->fbo.draw(-ofGetWidth() / 2, -ofGetHeight() / 2); // Draw Shadow ofPixels pixels; this->fbo.readToPixels(pixels); for (int y = 0; y < pixels.getHeight(); y++) { int noise_x = ofMap(ofNoise(y * 0.05 + ofGetFrameNum() * 0.05), 0, 1, -20, 20); noise_x = noise_x * ofMap(y, 0, pixels.getHeight(), 1, 0.1); if (noise_x > 0) { for (int x = pixels.getWidth() - 1; x > noise_x; x--) { pixels.setColor(x, y, pixels.getColor(x - noise_x, y)); } for (int x = 0; x < noise_x; x++) { pixels.setColor(x, y, ofColor(39)); } } else if (noise_x < 0) { for (int x = 0; x < pixels.getWidth() + noise_x; x++) { pixels.setColor(x, y, pixels.getColor(x - noise_x, y)); } for (int x = pixels.getWidth() + noise_x; x < pixels.getWidth(); x++) { pixels.setColor(x, y, ofColor(39)); } } } ofImage image; image.setFromPixels(pixels); ofRotate(180); ofRotateY(180); ofSetColor(255, 64); image.draw(-ofGetWidth() / 2, -ofGetHeight() / 2); ofDrawLine(-360, 0, 360, 0); } //-------------------------------------------------------------- int main() { ofSetupOpenGL(720, 720, OF_WINDOW); ofRunApp(new ofApp()); } |