[ Video ]
[ About ]
変化する数字。
Number is changing.
[ Souce ]
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 |
#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_blend_charactor(ofPoint point, char c1, char c2, float progress); int font_size; ofTrueTypeFont font; vector<char> charactors; }; |
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 |
#include "ofApp.h" //-------------------------------------------------------------- void ofApp::setup() { ofSetFrameRate(60); ofSetWindowTitle("openframeworks"); ofBackground(39); ofSetColor(239); ofEnableBlendMode(ofBlendMode::OF_BLENDMODE_ADD); this->font_size = 120; this->font.loadFont("fonts/Kazesawa-bold.ttf", this->font_size, true, true, true); this->charactors = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' }; } //-------------------------------------------------------------- void ofApp::update() { ofSeedRandom(39); } //-------------------------------------------------------------- void ofApp::draw() { for (int x = 72; x < ofGetWidth(); x += 144) { for (int y = 72; y < ofGetHeight(); y += 144) { float noise_value = ofMap(ofNoise(ofRandom(100), ofGetFrameNum() * 0.002), 0, 1, 0, 1000); int index = noise_value * 0.01; int next_index = (index + 1) % this->charactors.size(); int progress = noise_value - index * 100; this->draw_blend_charactor(ofPoint(x, y), this->charactors[index], this->charactors[next_index], progress); } } } //-------------------------------------------------------------- void ofApp::draw_blend_charactor(ofPoint point, char c1, char c2, float progress) { int total_sample_count = 60; ofPushMatrix(); ofTranslate(point); ofPath path = this->font.getCharacterAsPoints(c1, true, false); vector<ofPolyline> outline = path.getOutline(); int sample_count = total_sample_count / outline.size(); vector<ofPoint> points; for (int outline_index = 0; outline_index < (int)outline.size(); outline_index++) { outline[outline_index] = outline[outline_index].getResampledByCount(sample_count); vector<glm::vec3> vertices = outline[outline_index].getVertices(); for (size_t vertices_index = 0; vertices_index < vertices.size(); vertices_index++) { ofPoint point(vertices[vertices_index].x - this->font_size * 0.5, vertices[vertices_index].y + this->font_size * 0.5, vertices[vertices_index].z); points.push_back(point); } } ofPath next_path = this->font.getCharacterAsPoints(c2, true, false); vector<ofPolyline> next_outline = next_path.getOutline(); int next_sample_count = total_sample_count / next_outline.size(); vector<ofPoint> next_points; for (int outline_index = 0; outline_index < (int)next_outline.size(); outline_index++) { next_outline[outline_index] = next_outline[outline_index].getResampledByCount(next_sample_count); vector<glm::vec3> vertices = next_outline[outline_index].getVertices(); for (size_t vertices_index = 0; vertices_index < vertices.size(); vertices_index++) { ofPoint point(vertices[vertices_index].x - this->font_size * 0.5, vertices[vertices_index].y + this->font_size * 0.5, vertices[vertices_index].z); next_points.push_back(point); } } vector<ofPoint> draw_points; for (int i = 0; i < total_sample_count; i++) { if (i < points.size() && i < next_points.size()) { ofPoint p = (next_points[i] - points[i]) * progress * 0.01 + points[i]; draw_points.push_back(p); } } for (int i = 0; i < draw_points.size(); i++) { ofDrawCircle(draw_points[i], 2); for (int j = i + 1; j < draw_points.size(); j++) { if (draw_points[i].distance(draw_points[j]) < 15) { ofDrawLine(draw_points[i], draw_points[j]); } } } ofPopMatrix(); } //-------------------------------------------------------------- int main() { ofSetupOpenGL(720, 720, OF_WINDOW); ofRunApp(new ofApp()); } |