[ 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 29 30 31 |
#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) {}; ofTrueTypeFont font; int font_size; vector<string> words; vector<glm::vec2> location_list; vector<ofColor> color_list; vector<glm::vec2> velocity_list; vector<int> word_index_list; vector<ofColor> color_palette; }; |
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 |
#include "ofApp.h" //-------------------------------------------------------------- void ofApp::setup() { ofSetFrameRate(25); ofSetWindowTitle("openFrameworks"); ofBackground(239); ofSetLineWidth(1.5); \ this->font_size = 30; ofTrueTypeFontSettings font_settings("fonts/msgothic.ttc", this->font_size); font_settings.antialiased = true; font_settings.addRanges(ofAlphabet::Japanese); this->font.load(font_settings); this->words = { //u8"!", u8"#", u8"$", u8"%", u8"&", //u8"'", u8"(", u8")", u8"*", u8"+", //u8",", u8"-", u8".", u8"/", u8"0", //u8"1", u8"2", u8"3", u8"4", u8"5", //u8"6", u8"7", u8"8", u8"9", u8"0", //u8":", u8";", u8"<", u8"=", u8">", //u8"?", u8"@", //u8"A", u8"B", u8"C", u8"D", u8"E", //u8"F", u8"G", u8"H", u8"I", u8"J", //u8"K", u8"L", u8"M", u8"N", u8"O", //u8"P", u8"Q", u8"R", u8"S", u8"T", //u8"U", u8"V", u8"W", u8"X", u8"Y", u8"Z", //u8"a", u8"b", u8"c", u8"d", u8"e", //u8"f", u8"g", u8"h", u8"i", u8"j", //u8"k", u8"l", u8"m", u8"n", u8"o", //u8"p", u8"q", u8"r", u8"s", u8"t", //u8"u", u8"v", u8"w", u8"x", u8"y", u8"z", u8"ア", u8"イ", u8"ウ", u8"エ", u8"オ", u8"カ", u8"キ", u8"ク", u8"ケ", u8"コ", u8"サ", u8"シ", u8"ス", u8"セ", u8"ソ", u8"タ", u8"チ", u8"ツ", u8"テ", u8"ト", u8"ナ", u8"ニ", u8"ヌ", u8"ネ", u8"ノ", u8"ハ", u8"ヒ", u8"フ", u8"ヘ", u8"ホ", u8"マ", u8"ミ", u8"ム", u8"メ", u8"モ", u8"ヤ", u8"ユ", u8"ヨ", u8"ラ", u8"リ", u8"ル", u8"レ", u8"ロ", u8"ワ", u8"ヲ", u8"ン", }; //// 配色デザイン ビビッドレッド P038 this->color_palette.push_back(ofColor(197, 0, 24)); this->color_palette.push_back(ofColor(184, 12, 65)); this->color_palette.push_back(ofColor(206, 97, 110)); this->color_palette.push_back(ofColor(204, 85, 68)); this->color_palette.push_back(ofColor(190, 145, 176)); this->color_palette.push_back(ofColor(215, 130, 63)); this->color_palette.push_back(ofColor(255, 241, 51)); this->color_palette.push_back(ofColor(107, 182, 187)); // 配色デザイン ビビットパープル P168 this->color_palette.push_back(ofColor(109, 23, 129)); this->color_palette.push_back(ofColor(75, 83, 158)); this->color_palette.push_back(ofColor(132, 93, 159)); this->color_palette.push_back(ofColor(66, 35, 128)); this->color_palette.push_back(ofColor(200, 64, 114)); this->color_palette.push_back(ofColor(0, 160, 158)); this->color_palette.push_back(ofColor(215, 130, 63)); this->color_palette.push_back(ofColor(0, 0, 0)); } //-------------------------------------------------------------- void ofApp::update() { int index = 0; auto radius = ofMap(ofNoise(39, ofGetFrameNum() * 0.01), 0, 1, 100, 350); for (int x = -180; x <= 180; x += 360) { auto location = glm::vec2(x, x == -180 ? 230 : -230); auto next = glm::vec2(x, x == -180 ? 240 : -240); auto distance = location - next; distance *= 1; for (int i = 0; i < 2; i++) { auto future = location + distance * 15; auto random_deg = ofRandom(360); future += glm::vec2(45 * cos(random_deg * DEG_TO_RAD), 45 * sin(random_deg * DEG_TO_RAD)); auto future_distance = future - location; this->location_list.push_back(location); this->velocity_list.push_back(glm::normalize(future_distance) * glm::length(distance)); this->color_list.push_back(this->color_palette[ofRandom(1, this->color_palette.size())]); this->word_index_list.push_back(ofRandom(this->words.size())); } index++; } for (int i = this->location_list.size() - 1; i > -1; i--) { this->location_list[i] += this->velocity_list[i]; this->velocity_list[i] *= 1.01; if (glm::distance(glm::vec2(), this->location_list[i]) > 720) { this->location_list.erase(this->location_list.begin() + i); this->velocity_list.erase(this->velocity_list.begin() + i); this->color_list.erase(this->color_list.begin() + i); this->word_index_list.erase(this->word_index_list.begin() + i); } } } //-------------------------------------------------------------- void ofApp::draw() { ofTranslate(ofGetWindowSize() * 0.5); int index = 0; for (auto& location : this->location_list) { ofPushMatrix(); ofTranslate(location); ofSetColor(this->color_list[index]); auto angle = std::atan2(location.y - (location.y + this->velocity_list[index].y), location.x - (location.x + this->velocity_list[index].x)); ofRotate(angle * RAD_TO_DEG + 90); this->font.drawString(this->words[this->word_index_list[index]], 0, 0); ofPopMatrix(); index++; } /* int start = 150; if (ofGetFrameNum() > start) { ostringstream os; os << setw(4) << setfill('0') << ofGetFrameNum() - start; ofImage image; image.grabScreen(0, 0, ofGetWidth(), ofGetHeight()); image.saveImage("image/cap/img_" + os.str() + ".jpg"); if (ofGetFrameNum() - start >= 25 * 20) { std::exit(1); } } */ } //-------------------------------------------------------------- int main() { ofSetupOpenGL(720, 720, OF_WINDOW); ofRunApp(new ofApp()); } |