[ Video ]
[ About ]
中心からの距離をNoise関数の引数にして、画素の高さを決めています。
The distance from the center is taken as an argument of the noise function, and the height of the pixel is determined.
[ 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 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 49  | 
						#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); 			float distance = ofVec2f(pixels.getWidth() / 2, pixels.getHeight() / 2).distance(ofVec2f(x, y)); 			noise_value = ofNoise(distance * 0.008 + ofGetFrameNum() * 0.025); 			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()); }  |