[ Video ]
[ About ]
Dot font.
[ 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 |
#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) {}; ofTrueTypeFont font; vector<glm::vec2> location_list; vector<float> value_list; int frame_span; int word_index; }; |
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 |
#include "ofApp.h" //-------------------------------------------------------------- void ofApp::setup() { ofSetFrameRate(60); ofSetWindowTitle("openframeworks"); ofBackground(239); ofSetColor(39); this->font.loadFont("fonts/Kazesawa-Bold.ttf", 550, true, true, true); int span = 20; for (int x = span * 0.5; x <= ofGetWidth() - span * 0.5; x += span) { for (int y = span * 0.5; y <= ofGetHeight() - span * 0.5; y += span) { this->location_list.push_back(glm::vec2(x, y)); this->value_list.push_back(0); } } this->word_index = 0; this->frame_span = 90; } //-------------------------------------------------------------- void ofApp::update() { if (ofGetFrameNum() % this->frame_span == 0) { vector<string> word_list = { "L", "O", "V", "E", "!" }; this->word_index = (this->word_index + 1) % word_list.size(); string word = word_list[this->word_index]; ofFbo fbo; fbo.allocate(ofGetWidth(), ofGetHeight()); fbo.begin(); ofTranslate(ofGetWidth() * 0.5, ofGetHeight() * 0.5); ofClear(0); ofSetColor(0); this->font.drawString(word, font.stringWidth(word) * -0.5, font.stringHeight(word) * 0.5); fbo.end(); ofPixels pixels; fbo.readToPixels(pixels); for (int i = 0; i < this->location_list.size(); i++) { ofColor color = pixels.getColor(this->location_list[i].x, this->location_list[i].y); if (color != ofColor(0, 0)) { this->value_list[i] = 1; } else { this->value_list[i] = 0; } } } } //-------------------------------------------------------------- void ofApp::draw() { auto frame_param = ofGetFrameNum() % this->frame_span; for (int i = 0; i < this->location_list.size(); i++) { if (this->value_list[i] == 1) { auto noise_value = ofNoise(this->location_list[i] * 0.005); if (frame_param < this->frame_span * 0.6) { noise_value += ofMap(frame_param, 0, this->frame_span * 0.3, 0, 1); if (noise_value > 1) { noise_value = 1; } } else { noise_value = ofMap(frame_param , this->frame_span * 0.6, this->frame_span, 1, 0); if (noise_value < 0) { noise_value = 0; } } ofDrawCircle(this->location_list[i], 3 + 5 * this->value_list[i] * noise_value); } else { ofDrawCircle(this->location_list[i], 3); } } } //-------------------------------------------------------------- int main() { ofSetupOpenGL(720, 720, OF_WINDOW); ofRunApp(new ofApp()); } |