[ Video ]
[ About ]
動物(犬-Dog, やもり-Gecko, こうもり-Bat)のシルエットにお互いを結ぶ座標を置きました。
[ 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 |
#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) {}; vector<ofImage> images; int images_index; ofPixels pix; }; |
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); ofBackground(39); ofSetWindowTitle("Insta"); ofEnableBlendMode(ofBlendMode::OF_BLENDMODE_ADD); ofImage image_gecko; image_gecko.load("images/gecko.png"); ofImage image_dog; image_dog.load("images/dog.png"); ofImage image_bat; image_bat.load("images/bat.png"); this->images.push_back(image_gecko); this->images.push_back(image_dog); this->images.push_back(image_bat); this->images_index = -1; } //-------------------------------------------------------------- void ofApp::update() { ofSeedRandom(39); if (ofGetFrameNum() % 180 == 0) { this->images_index = (this->images_index + 1) % this->images.size(); this->pix = this->images[this->images_index].getPixelsRef(); } } //-------------------------------------------------------------- void ofApp::draw() { ofTranslate((ofGetWidth() - this->images[this->images_index].getWidth()) * 0.5, (ofGetHeight() - this->images[this->images_index].getHeight()) * 0.5); int number_of_circle = 550; vector<ofPoint> points; while (points.size() < number_of_circle) { int x = ofRandom(this->images[this->images_index].getWidth()); int y = ofRandom(this->images[this->images_index].getHeight()); ofColor pix_color = this->pix.getColor(x, y); if (pix_color != ofColor(0)) { continue; } float x_increase = ofMap(ofNoise(ofRandom(number_of_circle), ofGetFrameNum() * 0.005), 0, 1, -10, 10); float y_increase = ofMap(ofNoise(ofRandom(number_of_circle), ofGetFrameNum() * 0.005), 0, 1, -10, 10); x += x_increase; y += y_increase; points.push_back(ofPoint(x, y)); } ofColor color; for (int i = 0; i < points.size(); i++) { color.setHsb(ofRandom(255), 255, 255); ofSetColor(color); ofDrawCircle(points[i], 3); for (int j = 0; j < points.size(); j++) { float distance = points[i].distance(points[j]); if (distance < 50) { ofSetColor(color, ofMap(distance, 0, 50, 255, 0)); ofDrawLine(points[i], points[j]); } } } } //-------------------------------------------------------------- int main() { ofSetupOpenGL(720, 720, OF_WINDOW); ofRunApp(new ofApp()); } |