[ Video ]
[ About ]
四角形の回転で見るノイズ
Rect rotate by Noise.
[ Source ]
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
#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 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) {}; }; |
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 |
#include "ofApp.h" //-------------------------------------------------------------- void ofApp::setup() { ofSetFrameRate(60); ofSetWindowTitle("openframeworks"); ofBackground(39); ofSetColor(239); ofSetLineWidth(3); ofSetRectMode(ofRectMode::OF_RECTMODE_CENTER); ofSetDepthTest(true); } //-------------------------------------------------------------- void ofApp::update() { ofSeedRandom(39); } //-------------------------------------------------------------- void ofApp::draw() { int length = 30; int x_span = 20; int y_span = 20; for (int x = 0; x < ofGetWidth(); x += x_span) { for (int y = 0; y < ofGetHeight(); y += y_span) { ofColor color(ofRandom(255), 255, 255); ofSetColor(color); ofPushMatrix(); ofTranslate(x + x_span * 0.5, y + y_span * 0.5); ofRotateX(ofMap(ofNoise(x * 0.001, y * 0.001, ofGetFrameNum() * 0.005), 0, 1, 0, 360)); ofDrawRectangle(0, 0, x_span, y_span); ofPopMatrix(); } } } //-------------------------------------------------------------- int main() { ofGLWindowSettings settings; settings.setGLVersion(3, 2); settings.setSize(720, 720); ofCreateWindow(settings); ofRunApp(new ofApp()); } |