[ Video ]
[ About ]
絵文字マトリックス😎
Emoji Matrix 😎
[ 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 |
#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; int font_size; string moji; vector<string> words; vector<vector<string>> matrix; vector<int> random_values; }; |
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 |
#include "ofApp.h" //-------------------------------------------------------------- void ofApp::setup() { ofSetFrameRate(60); ofSetWindowTitle("openframeworks"); ofBackground(0); this->font_size = 15; ofTrueTypeFontSettings font_settings("fonts/EmojiSymbols-Regular.ttf", this->font_size); font_settings.antialiased = true; font_settings.addRanges(ofAlphabet::Emoji); this->font.load(font_settings); this->words = { u8"🍶", u8"🍷", u8"🍸", u8"🍹" , u8"🍺", u8"🍻", u8"🍎", u8"🎃", u8"🍭", u8"👻", u8"😁", u8"😍", u8"😂", u8"😱", u8"😎", u8"🎵", u8"🎶", }; for (int x = 0; x < ofGetWidth(); x += this->font_size) { vector<string> line; for (int y = 0; y <= ofGetHeight(); y += this->font_size) { line.push_back(this->words[(int)(ofRandom(this->words.size()))]); } this->matrix.push_back(line); this->random_values.push_back(ofRandom(ofGetHeight() * 1.5)); } } //-------------------------------------------------------------- void ofApp::update() { } //-------------------------------------------------------------- void ofApp::draw() { for (int row = 0; row < this->matrix.size(); row++) { int x = row * this->font_size; auto top = true; int random_value = this->random_values[row]; for (int col = 0; col < this->matrix[row].size(); col++) { int y = col * this->font_size * 1.25; int alpha = (random_value + ofGetFrameNum() * 4 + y) % (int)(ofGetHeight() * 1.5); if (alpha <= 255) { if (top) { this->matrix[row][col] = this->words[(int)(ofRandom(this->words.size()))]; top = false; } auto rb = ofMap(alpha, 0, 50, 239, 0); ofSetColor(rb, 239, rb, 255 - alpha); ofPushMatrix(); ofTranslate(x, ofGetHeight() - y); this->font.drawString(this->matrix[row][col], 0, 0); ofPopMatrix(); } } } } //-------------------------------------------------------------- int main() { ofSetupOpenGL(720, 720, OF_WINDOW); ofRunApp(new ofApp()); } |