[ Video ]
[ About ]
パラメータの変化の仕方を見比べる。
[ 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 |
#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) {}; float noise_param_1, noise_param_2; float font_size; ofTrueTypeFont font; }; |
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 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 |
#include "ofApp.h" //-------------------------------------------------------------- void ofApp::setup() { ofSetFrameRate(25); ofSetWindowTitle("openFrameworks"); ofBackground(39); ofSetColor(239); ofEnableDepthTest(); this->noise_param_1 = ofRandom(1000); this->noise_param_2 = ofRandom(1000); this->font_size = 40; this->font.loadFont("fonts/msgothic.ttc", this->font_size, true, true, true); } //-------------------------------------------------------------- void ofApp::update() { this->noise_param_1 += 0.025 * 2; if (ofGetFrameNum() % 50 < 20) { this->noise_param_2 += ofMap(ofGetFrameNum() % 50, 0, 20, 0.2, 0); } } //-------------------------------------------------------------- void ofApp::draw() { ofPushMatrix(); ofTranslate(ofGetWindowWidth() * 0.5, ofGetWindowHeight() * 0.25); ofSetColor(239); ofSetLineWidth(3); ofNoFill(); auto tmp_noise_param = this->noise_param_1; ofBeginShape(); for (int x = 0; x <= 330; x += 1) { auto y = ofMap(ofNoise(tmp_noise_param), 0, 1, -100, 100); ofVertex(x, y); tmp_noise_param += 0.025; } ofEndShape(); ofDrawLine(glm::vec2(0, -100), glm::vec2(0, 100)); ofDrawLine(glm::vec2(330, -100), glm::vec2(330, 100)); auto y = ofMap(ofNoise(this->noise_param_1), 0, 1, -100, 100); ofFill(); ofDrawCircle(0, y, 8); ofTranslate(-180, 0); ofSetColor(239); ofSetLineWidth(1.5); int noise_value = ofNoise(this->noise_param_1) * 100; this->font.drawString("0." + to_string(noise_value), -50, 20); tmp_noise_param = this->noise_param_1; for (int x = 0; x <= 10; x += 1) { auto deg = ofMap(ofNoise(tmp_noise_param), 0, 1, -180, 180); ofDrawCircle(glm::vec2(120 * cos(deg * DEG_TO_RAD), 120 * sin(deg * DEG_TO_RAD)), ofMap(x, 10, 0, 5, 0)); ofDrawCircle(glm::vec2(120 * cos((deg + 180) * DEG_TO_RAD), 120 * sin((deg + 180) * DEG_TO_RAD)), ofMap(x, 10, 0, 5, 0)); tmp_noise_param += 0.025; } ofPopMatrix(); ofPushMatrix(); ofTranslate(ofGetWindowWidth() * 0.5, ofGetWindowHeight() * 0.75); ofSetColor(239); ofSetLineWidth(3); ofNoFill(); tmp_noise_param = this->noise_param_2; ofBeginShape(); for (int x = 0; x <= 330; x += 1) { if (x > 0 && (ofGetFrameNum() + x) % 50 < 20) { tmp_noise_param += ofMap((ofGetFrameNum() + x) % 50, 0, 20, 0.2, 0); } y = ofMap(ofNoise(tmp_noise_param), 0, 1, -100, 100); ofVertex(x, y); } ofEndShape(); ofDrawLine(glm::vec2(0, -100), glm::vec2(0, 100)); ofDrawLine(glm::vec2(330, -100), glm::vec2(330, 100)); y = ofMap(ofNoise(this->noise_param_2), 0, 1, -100, 100); ofFill(); ofDrawCircle(0, y, 8); ofTranslate(-180, 0); ofSetColor(239); ofSetLineWidth(1.5); noise_value = ofNoise(this->noise_param_2) * 100; this->font.drawString("0." + to_string(noise_value), -50, 20); tmp_noise_param = this->noise_param_2; for (int x = 0; x <= 10; x += 1) { tmp_noise_param += 0.025; auto deg = ofMap(ofNoise(tmp_noise_param), 0, 1, -180, 180); ofDrawCircle(glm::vec2(120 * cos(deg * DEG_TO_RAD), 120 * sin(deg * DEG_TO_RAD)), ofMap(x, 10, 0, 5, 0)); ofDrawCircle(glm::vec2(120 * cos((deg + 180) * DEG_TO_RAD), 120 * sin((deg + 180) * DEG_TO_RAD)), ofMap(x, 10, 0, 5, 0)); } ofPopMatrix(); /* int start = 1; if (ofGetFrameNum() > start) { ostringstream os; os << setw(4) << setfill('0') << ofGetFrameNum() - start; ofImage image; image.grabScreen(0, 0, ofGetWidth(), ofGetHeight()); image.saveImage("image/cap/img_" + os.str() + ".jpg"); if (ofGetFrameNum() - start >= 25 * 20) { std::exit(1); } } */ } //-------------------------------------------------------------- int main() { ofSetupOpenGL(720, 720, OF_WINDOW); ofRunApp(new ofApp()); } |