[ Video ]
[ About ]
Ribbon tape.
[ Source ]
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
#pragma once #include "ofMain.h" #include "opencv2/opencv.hpp" 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; }; |
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 |
#include "ofApp.h" //-------------------------------------------------------------- void ofApp::setup() { ofSetFrameRate(60); ofSetWindowTitle("openFrameworks"); ofBackground(239); ofSetLineWidth(2); ofEnableDepthTest(); } //-------------------------------------------------------------- void ofApp::update() { } //-------------------------------------------------------------- void ofApp::draw() { vector<ofColor> base_color_list; ofColor color; vector<int> hex_list = { 0xef476f, 0xffd166, 0x06d6a0, 0x118ab2, 0x073b4c }; for (auto hex : hex_list) { color.setHex(hex); base_color_list.push_back(color); } int color_index = 0; this->cam.begin(); for (int radius = 30; radius <= 300; radius += 10) { ofMesh mesh, frame; frame.setMode(ofPrimitiveMode::OF_PRIMITIVE_LINES); auto deg_max = ofMap(ofNoise(radius * 0.005 + ofGetFrameNum() * 0.015), 0, 1, 0, 450); if (deg_max > 360) { deg_max = 360; } for (int deg = 0; deg < deg_max; deg += 1) { auto location = glm::vec2(radius * cos(deg * DEG_TO_RAD), radius * sin(deg * DEG_TO_RAD)); mesh.addVertex(glm::vec3(location, -30)); mesh.addVertex(glm::vec3(location, 30)); frame.addVertex(glm::vec3(location, -30)); frame.addVertex(glm::vec3(location, 30)); if (deg > 0) { mesh.addIndex(mesh.getNumVertices() - 1); mesh.addIndex(mesh.getNumVertices() - 2); mesh.addIndex(mesh.getNumVertices() - 4); mesh.addIndex(mesh.getNumVertices() - 1); mesh.addIndex(mesh.getNumVertices() - 3); mesh.addIndex(mesh.getNumVertices() - 4); frame.addIndex(frame.getNumVertices() - 1); frame.addIndex(frame.getNumVertices() - 3); frame.addIndex(frame.getNumVertices() - 2); frame.addIndex(frame.getNumVertices() - 4); } mesh.addColor(base_color_list[color_index]); mesh.addColor(base_color_list[color_index]); frame.addColor(ofColor(39)); frame.addColor(ofColor(39)); } frame.addIndex(0); frame.addIndex(1); frame.addIndex(frame.getNumVertices() - 1); frame.addIndex(frame.getNumVertices() - 2); mesh.draw(); frame.drawWireframe(); color_index = (color_index + 1) % base_color_list.size(); } this->cam.end(); } //-------------------------------------------------------------- int main() { ofSetupOpenGL(720, 720, OF_WINDOW); ofRunApp(new ofApp()); } |