[ Video ]
[ About ]
カラフルな山々。ゆらゆらしている図形を重ねて描写。
Color mountain. Overlap of shape.
[ Source ]
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
#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) {}; }; |
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 |
#include "ofApp.h" //-------------------------------------------------------------- void ofApp::setup() { ofSetFrameRate(60); ofSetWindowTitle("openFrameworks"); ofBackground(239); ofSetLineWidth(3); } //-------------------------------------------------------------- void ofApp::update() { ofSeedRandom(39); } //-------------------------------------------------------------- void ofApp::draw() { for (int y = 0; y <= ofGetHeight(); y += 50) { float noise_seed = ofRandom(1000); ofColor color; color.setHsb(ofMap(y, 0, ofGetHeight(), 0, 255), 200, 255); vector<glm::vec2> vertices; for (int x = 0; x <= ofGetWidth(); x += 3) { int noise_y = y + ofMap(ofNoise(noise_seed, x * 0.003, ofGetFrameNum() * 0.005), 0, 1, -150, 150); ofVertex(glm::vec2(x, noise_y)); vertices.push_back(glm::vec2(x, noise_y)); } vertices.push_back(glm::vec2(ofGetWidth(), ofGetHeight())); vertices.push_back(glm::vec2(0, ofGetHeight())); ofSetColor(color); ofFill(); ofBeginShape(); ofVertices(vertices); ofEndShape(true); ofSetColor(39); ofNoFill(); ofBeginShape(); ofVertices(vertices); ofEndShape(true); } } //-------------------------------------------------------------- int main() { ofSetupOpenGL(720, 720, OF_WINDOW); ofRunApp(new ofApp()); } |