[ Video ]
[ About ]
2021 Happy New Year !
[ 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 |
#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) {}; ofTrueTypeFont font; }; |
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 |
#include "ofApp.h" //-------------------------------------------------------------- void ofApp::setup() { ofSetFrameRate(60); ofSetWindowTitle("openFrameworks"); ofBackground(239); ofSetLineWidth(3); ofSetCircleResolution(60); ofEnableDepthTest(); font.loadFont("fonts/Kazesawa-Bold.ttf", 230, true, true, true); /* https://github.com/kazesawa/kazesawa */ } //-------------------------------------------------------------- void ofApp::update() { } //-------------------------------------------------------------- void ofApp::draw() { ofTranslate(ofGetWidth() * 0.5, ofGetHeight() * 0.5); int radius = 50; ofFill(); ofSetColor(230, 0, 82); ofDrawCircle(glm::vec2(ofGetWidth() * -0.1, 0), radius); auto deg_span = 5; for (auto deg_start = ofGetFrameNum() * 0.125; deg_start <= ofGetFrameNum() * 0.5 + 360; deg_start += deg_span * 2) { vector<glm::vec2> vertices_1, vertices_2; for (auto deg = deg_start; deg <= deg_start + deg_span; deg++) { vertices_1.push_back(glm::vec2((radius + 10) * cos(deg * DEG_TO_RAD) - ofGetWidth() * 0.1, (radius + 10) * sin(deg * DEG_TO_RAD))); vertices_2.push_back(glm::vec2((radius * 15) * cos(deg * DEG_TO_RAD) - ofGetWidth() * 0.1, (radius * 15) * sin(deg * DEG_TO_RAD))); } reverse(vertices_2.begin(), vertices_2.end()); ofBeginShape(); ofVertices(vertices_1); ofVertices(vertices_2); ofEndShape(true); } auto word = "2 21"; auto bound = this->font.getStringBoundingBox(word, 0, 0); auto path_list = font.getStringAsPoints(word, true, false); for (auto path : path_list) { auto outline = path.getOutline(); ofFill(); ofSetColor(239); ofBeginShape(); for (int outline_index = 0; outline_index < outline.size(); outline_index++) { if (outline_index != 0) { ofNextContour(true); } outline[outline_index] = outline[outline_index].getResampledByCount(300); auto vertices = outline[outline_index].getVertices(); for (int vertices_index = 0; vertices_index < vertices.size(); vertices_index++) { auto location = glm::vec3(vertices[vertices_index].x - bound.width * 0.5, vertices[vertices_index].y + bound.height * 0.5, 1); ofVertex(location); } } ofEndShape(); ofNoFill(); ofSetColor(230, 0, 82); ofBeginShape(); for (int outline_index = 0; outline_index < outline.size(); outline_index++) { if (outline_index != 0) { ofNextContour(true); } outline[outline_index] = outline[outline_index].getResampledByCount(300); auto vertices = outline[outline_index].getVertices(); for (int vertices_index = 0; vertices_index < vertices.size(); vertices_index++) { auto location = glm::vec3(vertices[vertices_index].x - bound.width * 0.5, vertices[vertices_index].y + bound.height * 0.5, 1); ofVertex(location); } } ofEndShape(); } } //-------------------------------------------------------------- int main() { ofSetupOpenGL(720, 720, OF_WINDOW); ofRunApp(new ofApp()); } |