[ Video ]
[ About ]
R/G/B/Frame NumberをNoise関数の引数にして、画素の高さを決めています。
The pixel height is determined by using R/G/B/Frame Number as an argument of Noise function.
[ 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 25 |
#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 lenna; 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 |
#include "ofApp.h" //-------------------------------------------------------------- void ofApp::setup() { ofSetFrameRate(60); ofBackground(255); ofSetWindowTitle("Insta"); ofSetDepthTest(true); this->lenna.loadImage("Lenna.png"); } //-------------------------------------------------------------- void ofApp::update(){ } //-------------------------------------------------------------- void ofApp::draw() { this->cam.begin(); ofRotateZ(180); ofPixels pixels = this->lenna.getPixelsRef(); ofColor pixel_color; float noise_value; float height; int size = 3; for (int x = 0; x < pixels.getWidth(); x += size) { for (int y = 0; y < pixels.getHeight(); y += size) { pixel_color = pixels.getColor(x, y); ofSetColor(pixel_color); noise_value = ofNoise(pixel_color.r * 0.005, pixel_color.g * 0.005, pixel_color.b * 0.005, ofGetFrameNum() * 0.05); height = 300 * noise_value; ofDrawBox(ofVec3f(x - ofGetWidth() / 2, y - ofGetHeight() / 2, height / 2), size, size, height); } } this->cam.end(); } //-------------------------------------------------------------- int main() { ofSetupOpenGL(512, 512, OF_WINDOW); ofRunApp(new ofApp()); } |