[ Video ]
[ About ]
Instagramを中心とした、SNSへの500日連続投稿を達成しました。こんなに続くとは思ってなくて、正確に記録・カウントしていないのでちょっとアバウトですが。抜けは無いはずなので、ズレはあったとしても投稿はしているはず…
当初、500dayという文字で作っていたんですが、リーバイスのジーンズの誕生日が501dayというイベントである事を知り、デニム好きとして、そちらに寄せてみました。背景色もデニム色っぽモノにしてあります。
[ 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 26 27 28 29 30 31 32 33 |
#pragma once #include "ofMain.h" #include "ofxTrueTypeFontUC/src/ofxTrueTypeFontUC.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) {}; ofFbo fbo; ofPixels pix; ofxTrueTypeFontUC font; vector<tuple<ofColor, ofPoint, float>> circles; void draw_shapes(ofPoint point, float radius, ofColor color); void draw_circle(float radius, ofColor color); void draw_star(float radius, ofColor color); void draw_rectangle(float radius, ofColor color); void draw_triangle(float radius, ofColor color); }; |
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 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 |
#include "ofApp.h" //-------------------------------------------------------------- void ofApp::setup() { ofSetFrameRate(60); ofBackground(39); ofSetWindowTitle("Insta"); ofSetRectMode(ofRectMode::OF_RECTMODE_CENTER); this->font.loadFont("fonts/Kazesawa-Bold.ttf", 230, true, true); this->fbo.allocate(ofGetWidth(), ofGetHeight()); } //-------------------------------------------------------------- void ofApp::update() { ofSeedRandom(39); this->fbo.begin(); ofSetColor(0); string word_1 = "500"; this->font.drawString(word_1, ofGetWidth() / 2 - this->font.stringWidth(word_1) / 2, ofGetHeight() / 2); string word_2 = "days"; this->font.drawString(word_2, ofGetWidth() / 2 - this->font.stringWidth(word_2) / 2, ofGetHeight() / 2 + this->font.stringHeight(word_1)); this->fbo.end(); this->fbo.readToPixels(this->pix); } //-------------------------------------------------------------- void ofApp::draw() { //this->fbo.draw(0, 0); while (circles.size() < 1500) { int x = ofRandom(ofGetWidth()); int y = ofRandom(ofGetHeight()); ofColor pix_color = this->pix.getColor(x, y); if (pix_color != ofColor(0)) { continue; } ofColor color; color.setHsb(ofRandom(255), 239, 239); ofPoint point = ofPoint(x, y); float radius = ofRandom(2, 20); bool flag = true; for (int i = 0; i < circles.size(); i++) { if (point.distance(get<1>(circles[i])) < get<2>(circles[i]) + radius) { flag = false; break; } } if (flag) { circles.push_back(make_tuple(color, point, radius)); } } for (int circles_index = 0; circles_index < circles.size(); circles_index++) { ofColor color = get<0>(circles[circles_index]); ofPoint point = get<1>(circles[circles_index]); float radius = get<2>(circles[circles_index]); this->draw_shapes(point, radius, color); } ofPopMatrix(); } //-------------------------------------------------------------- void ofApp::draw_shapes(ofPoint point, float radius, ofColor color) { ofPushMatrix(); ofTranslate(point); ofSetColor(color); int type = ofRandom(4); switch (type) { case 0: this->draw_circle(radius, color); break; case 1: this->draw_star(radius, color); break; case 2: this->draw_rectangle(radius, color); break; case 3: this->draw_triangle(radius, color); break; } ofPopMatrix(); } //-------------------------------------------------------------- void ofApp::draw_circle(float radius, ofColor color) { if (ofRandom(1) < 0.2) { ofNoFill(); ofDrawCircle(ofPoint(0, 0), radius); ofFill(); ofSetColor(color); float tmp_deg = ofRandom(360); ofPoint point = ofPoint(radius * 0.6 * cos((tmp_deg + ofGetFrameNum()) * DEG_TO_RAD), radius * 0.6 * sin((tmp_deg + ofGetFrameNum()) * DEG_TO_RAD)); ofDrawCircle(point, radius * 0.3); } else { ofFill(); ofDrawCircle(ofPoint(0, 0), radius); ofSetColor(39); float tmp_deg = ofRandom(360); ofPoint point = ofPoint(radius * 0.6 * cos((tmp_deg + ofGetFrameNum()) * DEG_TO_RAD), radius * 0.6 * sin((tmp_deg + ofGetFrameNum()) * DEG_TO_RAD)); ofDrawCircle(point, radius * 0.3); } } //-------------------------------------------------------------- void ofApp::draw_star(float radius, ofColor color) { ofRandom(1) < 0.2 ? ofNoFill() : ofFill(); ofRotate(ofRandom(360)); radius = ofMap(ofNoise(ofRandom(1) + ofGetFrameNum() * 0.05), 0, 1, radius * 0.5, radius); ofBeginShape(); for (int deg = 0; deg < 360; deg += 30) { if (deg % 60 == 0) { ofVertex(radius * 0.5 * cos(deg * DEG_TO_RAD), radius * 0.5 * sin(deg * DEG_TO_RAD)); } else { ofVertex(radius * cos(deg * DEG_TO_RAD), radius * sin(deg * DEG_TO_RAD)); } } ofEndShape(true); } //-------------------------------------------------------------- void ofApp::draw_rectangle(float radius, ofColor color) { ofRandom(1) < 0.2 ? ofNoFill() : ofFill(); ofRotate(ofRandom(360)); ofColor tmp_color; tmp_color.setHsb((int)(ofRandom(255) + ofGetFrameNum()) % 255, 239, 239); ofSetColor(tmp_color); ofDrawRectangle(ofPoint(), radius, radius); } //-------------------------------------------------------------- void ofApp::draw_triangle(float radius, ofColor color) { ofRandom(1) < 0.2 ? ofNoFill() : ofFill(); ofRotate(ofRandom(360) + ofGetFrameNum()); ofBeginShape(); for (int deg = 0; deg < 360; deg += 120) { ofVertex(radius * cos(deg * DEG_TO_RAD), radius * sin(deg * DEG_TO_RAD)); } ofEndShape(true); } //-------------------------------------------------------------- int main() { ofSetupOpenGL(720, 720, OF_WINDOW); ofRunApp(new ofApp()); } |