[ Video ]
[ About ]
キラ☆キラ☆フォント
Light 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 27 |
#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) {}; ofShader shader; int number_of_targets; vector<glm::vec4> targets; vector<float> sizes; }; |
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 |
#include "ofApp.h" //-------------------------------------------------------------- void ofApp::setup() { ofSetFrameRate(60); ofSetWindowTitle("openframeworks"); ofTrueTypeFont font; font.loadFont("fonts/Kazesawa-bold.ttf", 350, true, true, true); string word = "EX"; int sample_count = 200; this->number_of_targets = sample_count * word.size(); ofPoint word_size(font.stringWidth(word), font.stringHeight(word)); vector<ofPath> word_path = font.getStringAsPoints(word, true, false); for (int word_index = 0; word_index < word.size(); word_index++) { vector<ofPolyline> outline = word_path[word_index].getOutline(); int tmp_sample_count = sample_count / outline.size(); for (int outline_index = 0; outline_index < outline.size(); outline_index++) { outline[outline_index] = outline[outline_index].getResampledByCount(tmp_sample_count); vector<glm::vec3> vertices = outline[outline_index].getVertices(); for (int vertices_index = 0; vertices_index < vertices.size(); vertices_index++) { glm::vec4 target = glm::vec4(vertices[vertices_index].x, vertices[vertices_index].y, vertices[vertices_index].z, 0.0); target += glm::vec4(word_size.x * -0.5 + ofGetWidth() * 0.5, word_size.y * 0.5 + ofGetHeight() * 0.5, 0.0, 0.0); this->targets.push_back(target); glm::vec4 color = glm::vec4(1.0, 1.0, 1.0, 0.0); this->sizes.push_back(1.0); } } } while (this->targets.size() < sample_count * word.size()) { this->targets.push_back(glm::vec4(0.0, 0.0, 0.0, 0.0)); this->sizes.push_back(0.0); } cout << this->targets.size() << endl; this->shader.load("shader/shader.vert", "shader/shader.frag"); } //-------------------------------------------------------------- void ofApp::update() { for (int i = 0; i < this->targets.size(); i++) { if (this->targets[i] == glm::vec4(0.0, 0.0, 0.0, 0.0)) { continue; } this->sizes[i] = ofNoise(this->targets[i].x * 0.05, this->targets[i].y * 0.05, ofGetFrameNum() * 0.05); } } //-------------------------------------------------------------- void ofApp::draw() { vector<glm::vec4> points; for (int i = 0; i < this->number_of_targets; i++) { glm::vec4 p = glm::vec4(this->targets[i].x, this->targets[i].y, 0, 0); points.push_back(p); } this->shader.begin(); this->shader.setUniform1f("time", ofGetElapsedTimef()); this->shader.setUniform2f("resolution", ofGetWidth(), ofGetHeight()); this->shader.setUniform4fv("targets", &points[0].x, this->number_of_targets); this->shader.setUniform1fv("sizes", &this->sizes[0], this->number_of_targets); ofRect(0, 0, ofGetWidth(), ofGetHeight()); this->shader.end(); } //-------------------------------------------------------------- int main() { ofGLWindowSettings settings; settings.setGLVersion(3, 2); settings.setSize(720, 720); ofCreateWindow(settings); ofRunApp(new ofApp()); } |
1 2 3 4 5 6 7 8 |
#version 150 uniform mat4 modelViewProjectionMatrix; in vec4 position; void main(){ gl_Position = modelViewProjectionMatrix * position; } |
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 |
#version 150 const int number_of_targets = 400; out vec4 outputColor; uniform float time; uniform vec2 resolution; uniform vec4 targets[number_of_targets]; uniform float sizes[number_of_targets]; void main() { vec2 p = (gl_FragCoord.xy * 2.0 - resolution) / min(resolution.x, resolution.y); vec3 color = vec3(0.0); for(int i = 0; i < number_of_targets; i++){ vec2 t = vec2(targets[i].x, -targets[i].y) / min(resolution.x, resolution.y) * 2.0; t.xy += vec2(-resolution.x, resolution.y) / min(resolution.x, resolution.y); float v = (0.012 * sizes[i]) / length(p - t); v = smoothstep(0.03, 1.0, v); vec3 c = vec3(v); color += c; } outputColor = vec4(color, 1.0); } |