[ Video ]
[ About ]
FF14の零式が実装されました。私は忙しいです。
FF14 Zero has been implemented. I’m busy.
[ Source ]
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
#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) {}; }; |
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 |
#include "ofApp.h" //-------------------------------------------------------------- void ofApp::setup() { ofSetFrameRate(30); ofSetWindowTitle("openFrameworks"); ofBackground(255); ofSetLineWidth(2); ofSetCircleResolution(36); } //-------------------------------------------------------------- void ofApp::update() { ofSeedRandom(39); } //-------------------------------------------------------------- void ofApp::draw() { ofTranslate(ofGetWindowSize() * 0.5); vector<ofColor> base_color_list; vector<int> hex_list = { 0xf44336, 0x9C27B0, 0x3F51B5, 0x03A9F4, 0x009688, 0x8BC34A, 0xFFEB3B, 0xFF9800 }; for (auto hex : hex_list) { ofColor color; color.setHex(hex); base_color_list.push_back(color); } int radius = 28; int width = 7; for (int x = -radius * 10; x <= radius * 10; x += radius * 2.5) { for (int y = -radius * 8; y <= radius * 8; y += radius * 4) { auto top = glm::vec3(x + 0, y - radius + width * 0.5, 0); auto bottom = glm::vec3(x + 0, y + radius - width * 0.5, 0); ofSetColor(255, 64); ofDrawCircle(top, radius); ofDrawCircle(top, radius - width); ofDrawCircle(bottom, radius); ofDrawCircle(bottom, radius - width); int deg_span = 30; int p = ofMap(ofNoise(ofRandom(1000), ofGetFrameNum() * 0.015), 0, 1, 0, 1440); int max_i = ofRandom(8, 20); for (int i = 0; i < max_i; i++) { int param = (p + i * deg_span) % 720; ofColor face_color = base_color_list[ofRandom(base_color_list.size())]; if (param < 360) { int deg_start = param / deg_span * deg_span + 270; for (int deg = deg_start + 1; deg <= deg_start + deg_span - 1; deg += 1) { vector<glm::vec3> vertices; vertices.push_back(bottom + glm::vec3((radius - width) * cos(deg * DEG_TO_RAD), (radius - width) * sin(deg * DEG_TO_RAD), 0)); vertices.push_back(bottom + glm::vec3((radius - width) * cos((deg + 1) * DEG_TO_RAD), (radius - width) * sin((deg + 1) * DEG_TO_RAD), 0)); vertices.push_back(bottom + glm::vec3(radius * cos((deg + 1) * DEG_TO_RAD), radius * sin((deg + 1) * DEG_TO_RAD), 0)); vertices.push_back(bottom + glm::vec3(radius * cos(deg * DEG_TO_RAD), radius * sin(deg * DEG_TO_RAD), 0)); ofMesh face, line; line.setMode(ofPrimitiveMode::OF_PRIMITIVE_LINES); face.addVertices(vertices); line.addVertices(vertices); face.addIndex(0); face.addIndex(1); face.addIndex(2); face.addIndex(0); face.addIndex(2); face.addIndex(3); line.addIndex(0); line.addIndex(1); line.addIndex(2); line.addIndex(3); if (deg == deg_start + 1) { line.addIndex(0); line.addIndex(3); } else if (deg == deg_start + deg_span - 1) { line.addIndex(1); line.addIndex(2); } ofSetColor(face_color, 100); face.draw(); ofSetColor(face_color); line.drawWireframe(); } } else { int deg_start = 720 - param / deg_span * deg_span + 90; for (int deg = deg_start - 1; deg >= deg_start - deg_span + 1; deg -= 1) { vector<glm::vec3> vertices; vertices.push_back(top + glm::vec3((radius - width) * cos(deg * DEG_TO_RAD), (radius - width) * sin(deg * DEG_TO_RAD), 0)); vertices.push_back(top + glm::vec3((radius - width) * cos((deg - 1) * DEG_TO_RAD), (radius - width) * sin((deg - 1) * DEG_TO_RAD), 0)); vertices.push_back(top + glm::vec3(radius * cos((deg - 1) * DEG_TO_RAD), radius * sin((deg - 1) * DEG_TO_RAD), 0)); vertices.push_back(top + glm::vec3(radius * cos(deg * DEG_TO_RAD), radius * sin(deg * DEG_TO_RAD), 0)); ofMesh face, line; line.setMode(ofPrimitiveMode::OF_PRIMITIVE_LINES); face.addVertices(vertices); line.addVertices(vertices); face.addIndex(0); face.addIndex(1); face.addIndex(2); face.addIndex(0); face.addIndex(2); face.addIndex(3); line.addIndex(0); line.addIndex(1); line.addIndex(2); line.addIndex(3); if (deg == deg_start - 1) { line.addIndex(0); line.addIndex(3); } else if (deg == deg_start - deg_span + 1) { line.addIndex(1); line.addIndex(2); } ofSetColor(face_color, 100); face.draw(); ofSetColor(face_color); line.drawWireframe(); } } } } } } //-------------------------------------------------------------- int main() { ofSetupOpenGL(720, 720, OF_WINDOW); ofRunApp(new ofApp()); } |