[ Video ]
[ About ]
ofxTrueTypeFontUCというAddonを入れて日本語取り扱えれるようにしました。
Install ofxTrueTypeFontUC. I can use Japanese.
※コードに誤りがあったため、修正します 2018/04/11
[ 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 |
#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 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) {}; ofxTrueTypeFontUC font; vector<ofTTFCharacter> word_paths; ofEasyCam cam; string word; }; |
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 |
#include "ofApp.h" //-------------------------------------------------------------- void ofApp::setup() { ofSetFrameRate(60); ofBackground(255); ofSetWindowTitle("Insta"); //ofNoFill(); ofSetColor(0); this->font.loadFont("fonts/Kazesawa-Bold.ttf", 300, true, true); this->word = "純"; this->word_paths = this->font.getStringAsPoints(this->word); } //-------------------------------------------------------------- void ofApp::update() { } //-------------------------------------------------------------- void ofApp::draw() { this->cam.begin(); // changed 2018/04/11 junkiyoshi //for (int w_index = 0; w_index < this->word.size(); w_index += 2) { // 日本語なので2Byte?? for (int w_index = 0; w_index < this->word_paths.size(); w_index++) { vector<ofPolyline> outline = word_paths[w_index].getOutline(); ofVec3f center = outline[0].getCentroid2D(); for (int o_index = 0; o_index < outline.size(); o_index++) { outline[o_index] = outline[o_index].getResampledBySpacing(3); vector<ofPoint> vertices = outline[o_index].getVertices(); for (int v_index = 0; v_index < vertices.size() - 1; v_index++) { ofVec3f point_1 = vertices[v_index] - center; ofVec3f point_2 = vertices[v_index + 1] - center; float noise_value_1 = ofNoise(v_index * 0.01 + ofGetFrameNum() * 0.01); float noise_value_2 = ofNoise((v_index + 1) * 0.01 + ofGetFrameNum() * 0.01); if (noise_value_1 < 0.5) { noise_value_1 = 0.5; } if (noise_value_2 < 0.5) { noise_value_2 = 0.5; } noise_value_1 -= 0.5; noise_value_2 -= 0.5; ofBeginShape(); ofVertex(point_1); ofVertex(point_2); ofVertex(point_2 + ofVec3f(0, 0, -300 * noise_value_2 + 1)); ofVertex(point_1 + ofVec3f(0, 0, -300 * noise_value_1 + 1)); ofEndShape(true); } } } this->cam.end(); } //-------------------------------------------------------------- int main() { ofSetupOpenGL(720, 720, OF_WINDOW); ofRunApp(new ofApp()); } |
[ Link ]
https://github.com/junkiyoshi/Insta20180110
ofxTrueTypeFontUC
https://github.com/hironishihara/ofxTrueTypeFontUC