[ Video ]
[ About ]
Day 19 Eggs.
ゆで卵と目玉焼き。
卵の座標計算は下記サイトを参考にさせて頂きました。
卵形の曲線を表す方程式 Ⅴ
http://www.geocities.jp/nyjp07/index_egg5.html
Boiled eggs and fried eggs.
[ 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 |
#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) {}; void draw_egg(ofPoint location, float len, bool fried); }; |
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 |
#include "ofApp.h" //-------------------------------------------------------------- void ofApp::setup() { ofSetFrameRate(60); ofSetWindowTitle("openFrameworks"); ofBackground(39); } //-------------------------------------------------------------- void ofApp::update() { ofSeedRandom(39); } //-------------------------------------------------------------- void ofApp::draw() { int len = 72; bool fried = false; for (int x = len; x < ofGetWidth(); x += len * 2) { for (int y = len; y < ofGetHeight(); y += len * 2) { this->draw_egg(ofPoint(x, y), len - 10, fried); fried = !fried; } } } //-------------------------------------------------------------- void ofApp::draw_egg(ofPoint location, float len, bool fried) { float a = 1; float b = 0.72; float c = 0.08; ofPushMatrix(); ofTranslate(location); ofRotate(90); ofSetColor(239); ofBeginShape(); for (int deg = 0; deg < 360; deg += 1) { float x = a * cos(deg * DEG_TO_RAD); float y = (b + c * cos(deg * DEG_TO_RAD)) * sin(deg * DEG_TO_RAD); float noise_value = fried ? ofMap(ofNoise(location.x * 0.005 + x, location.y * 0.05 + y, ofGetFrameNum() * 0.005), 0, 1, 0.7, 1.2) : 1; ofPoint p = ofPoint(x, y) * len * noise_value; ofVertex(p); } ofEndShape(); if (fried) { ofSetColor(220, 220, 39); ofDrawCircle(ofPoint(), len * 0.4); } ofPopMatrix(); } //-------------------------------------------------------------- int main() { ofSetupOpenGL(720, 720, OF_WINDOW); ofRunApp(new ofApp()); } |