[ Video ]
[ About ]
もじおらま。夏の海・エディション
[ 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 |
#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 windowResized(int w, int h) {}; void dragEvent(ofDragInfo dragInfo) {}; void gotMessage(ofMessage msg) {}; ofEasyCam cam; ofTrueTypeFont font; ofTrueTypeFont font_small; void draw_ocean(); void draw_beach(); void draw_human(ofPoint point); }; |
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 |
#include "ofApp.h" //-------------------------------------------------------------- void ofApp::setup() { ofSetFrameRate(30); ofBackground(239); ofSetWindowTitle("Insta"); ofEnableDepthTest(); this->font.loadFont("fonts/Kazesawa-Extrabold.ttf", 50, true, false, true); this->font_small.loadFont("fonts/Kazesawa-Extrabold.ttf", 25, true, false, true); } //-------------------------------------------------------------- void ofApp::update() { ofSeedRandom(39); } //-------------------------------------------------------------- void ofApp::draw() { this->cam.begin(); ofRotateX(180); this->draw_ocean(); this->draw_beach(); for (int i = 0; i < 18; i++) { this->draw_human(ofPoint(ofRandom(ofGetWidth() * -0.5, ofGetWidth() * 0.5), ofRandom(0, ofGetHeight() * 0.5), 80)); } this->cam.end(); } //-------------------------------------------------------------- void ofApp::draw_ocean() { ofSetColor(0, 0, 139); std::string words = "Ocean"; ofPoint words_size = ofPoint(this->font.stringWidth(words), this->font.stringHeight(words)); std::vector<ofPath> paths = this->font.getStringAsPoints(words, true, false); for (int x = ofGetWidth() * -0.8; x < ofGetWidth() * 0.8; x += words_size.x) { for (int y = 0; y < ofGetHeight(); y += words_size.y) { ofPoint words_center(x + words_size.x / 2, y - words_size.y / 2); for (int p_index = 0; p_index < paths.size(); p_index++) { vector<ofPolyline> outline = paths[p_index].getOutline(); std::vector<ofPoint> points; for (int o_index = 0; o_index < outline.size(); o_index++) { if (o_index > 0) { ofNextContour(true); } outline[o_index] = outline[o_index].getResampledBySpacing(1); vector<glm::vec3> vertices = outline[o_index].getVertices(); for (int v_index = 0; v_index < vertices.size(); v_index++) { ofPoint point = ofPoint(vertices[v_index].x, vertices[v_index].y, vertices[v_index].z) - words_center; float z = ofMap(ofNoise(point.x * 0.001, point.y * 0.005 - ofGetFrameNum() * 0.01), 0, 1, 0, 80); points.push_back(point + ofPoint(0, 0, z)); } } if (points.size() > 0) { ofBeginShape(); ofVertices(points); ofEndShape(true); } } } } } //-------------------------------------------------------------- void ofApp::draw_beach() { ofSetColor(232, 202, 179); std::string words = "Beach"; ofPoint words_size = ofPoint(this->font.stringWidth(words), this->font.stringHeight(words)); std::vector<ofPath> paths = this->font.getStringAsPoints(words, true, false); for (int x = ofGetWidth() * -0.5; x < ofGetWidth() * 0.5; x += words_size.x) { for (int y = ofGetHeight() * -0.5; y < 0; y += words_size.y) { ofPoint words_center(x + words_size.x / 2, y - words_size.y / 2); for (int p_index = 0; p_index < paths.size(); p_index++) { vector<ofPolyline> outline = paths[p_index].getOutline(); std::vector<ofPoint> points; for (int o_index = 0; o_index < outline.size(); o_index++) { if (o_index > 0) { ofNextContour(true); } outline[o_index] = outline[o_index].getResampledBySpacing(1); vector<glm::vec3> vertices = outline[o_index].getVertices(); for (int v_index = 0; v_index < vertices.size(); v_index++) { ofPoint point = ofPoint(vertices[v_index].x, vertices[v_index].y, vertices[v_index].z) - words_center; points.push_back(point + ofPoint(0, 0, 80)); } } if (points.size() > 0) { ofBeginShape(); ofVertices(points); ofEndShape(true); } } } } } //-------------------------------------------------------------- void ofApp::draw_human(ofPoint point) { ofColor color; color.setHsb(ofRandom(255), 200, 255); ofSetColor(color); vector<string> words = {"H", "u", "m", "a", "n" }; ofPushMatrix(); ofTranslate(point); ofRotateX(270); for (int i = words.size() - 1; i > -1; i--) { this->font_small.drawString(words[i], this->font_small.stringWidth(words[i]) * -0.5, 0); float noise_value = ofMap(ofNoise(point.x * 0.005, point.y * 0.005, ofGetFrameNum() * 0.005), 0, 1, -5, 5); ofTranslate(noise_value, this->font_small.stringHeight(words[i])); } ofPopMatrix(); } //-------------------------------------------------------------- int main() { ofSetupOpenGL(720, 720, OF_WINDOW); ofRunApp(new ofApp()); } |