[ Video ]
[ About ]
文字で型抜く。
Die cutting.
[ 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) {}; ofEasyCam cam; float random_seed; 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 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 |
#include "ofApp.h" //-------------------------------------------------------------- void ofApp::setup() { ofSetFrameRate(60); ofSetWindowTitle("openFrameworks"); ofBackground(0); ofEnableDepthTest(); this->font.loadFont("fonts/Kazesawa-Bold.ttf", 100, true, true, true); } //-------------------------------------------------------------- void ofApp::update() { if (ofGetFrameNum() % 60 == 0) { this->random_seed = ofRandom(1000); } } //-------------------------------------------------------------- void ofApp::draw() { this->cam.begin(); ofRotateX(180); ofRotateY(ofGetFrameNum()); string word = "ULTRAMAN"; ofColor color; ofSeedRandom(this->random_seed); ofFill(); for (int z = -150; z <= 150; z += 150) { color.setHsb(ofRandom(255), 130, 255); ofSetColor(color); ofPushMatrix(); ofTranslate(0, 0, z); vector<glm::vec2> location_list; vector<float> radius_list; while (location_list.size() < 120) { int x = ofRandom(-320, 320); int y = ofRandom(-320, 320); glm::vec2 location = glm::vec2(x, y); float radius = ofRandom(10, 120); if (location.x + radius > 320 || location.x - radius < -320 || location.y + radius > 320 || location.y - radius < -320) { continue; } bool flag = true; for (int i = 0; i < location_list.size(); i++) { if (glm::distance(location, location_list[i]) < radius_list[i] + radius) { flag = false; break; } } if (flag) { location_list.push_back(location); radius_list.push_back(radius); } } ofBeginShape(); ofVertex(glm::vec2(-360, -360)); ofVertex(glm::vec2(-360, 360)); ofVertex(glm::vec2(360, 360)); ofVertex(glm::vec2(360, -360)); for (int i = 0; i < location_list.size(); i++) { int word_index = ofRandom(word.size()); ofPath chara_path = this->font.getCharacterAsPoints(word[word_index], true, false); vector<ofPolyline> outline = chara_path.getOutline(); int rotate_deg = ofRandom(360); auto rotation = glm::rotate(glm::mat4(), rotate_deg * (float)DEG_TO_RAD, glm::vec3(0, 0, 1)); for (int outline_index = 0; outline_index < outline.size(); outline_index++) { ofNextContour(true); auto vertices = outline[outline_index].getVertices(); for (auto& vertex : vertices) { glm::vec2 location = vertex / 100 * radius_list[i] * 1.5; location -= glm::vec2(radius_list[i] * 0.75, -radius_list[i] * 0.75); location = glm::vec4(location, 0, 0) * rotation; ofVertex(location + location_list[i]); } } } ofEndShape(true); ofPopMatrix(); } ofSeedRandom(this->random_seed); ofNoFill(); ofSetColor(255); for (int z = -150; z <= 150; z += 150) { color.setHsb(ofRandom(255), 180, 255); ofPushMatrix(); ofTranslate(0, 0, z); vector<glm::vec2> location_list; vector<float> radius_list; while (location_list.size() < 120) { int x = ofRandom(-320, 320); int y = ofRandom(-320, 320); glm::vec2 location = glm::vec2(x, y); float radius = ofRandom(10, 120); if (location.x + radius > 320 || location.x - radius < -320 || location.y + radius > 320 || location.y - radius < -320) { continue; } bool flag = true; for (int i = 0; i < location_list.size(); i++) { if (glm::distance(location, location_list[i]) < radius_list[i] + radius) { flag = false; break; } } if (flag) { location_list.push_back(location); radius_list.push_back(radius); } } ofBeginShape(); ofVertex(glm::vec2(-360, -360)); ofVertex(glm::vec2(-360, 360)); ofVertex(glm::vec2(360, 360)); ofVertex(glm::vec2(360, -360)); for (int i = 0; i < location_list.size(); i++) { int word_index = ofRandom(word.size()); ofPath chara_path = this->font.getCharacterAsPoints(word[word_index], true, false); vector<ofPolyline> outline = chara_path.getOutline(); int rotate_deg = ofRandom(360); auto rotation = glm::rotate(glm::mat4(), rotate_deg * (float)DEG_TO_RAD, glm::vec3(0, 0, 1)); for (int outline_index = 0; outline_index < outline.size(); outline_index++) { ofNextContour(true); auto vertices = outline[outline_index].getVertices(); for (auto& vertex : vertices) { glm::vec2 location = vertex / 100 * radius_list[i] * 1.5; location -= glm::vec2(radius_list[i] * 0.75, -radius_list[i] * 0.75); location = glm::vec4(location, 0, 0) * rotation; ofVertex(location + location_list[i]); } } } ofEndShape(true); ofPopMatrix(); } this->cam.end(); } //-------------------------------------------------------------- int main() { ofSetupOpenGL(720, 720, OF_WINDOW); ofRunApp(new ofApp()); } |