/src/testApp.h
C Header | 78 lines | 59 code | 19 blank | 0 comment | 2 complexity | d9e14fbd9961c2bd2430b0ad77acb164 MD5 | raw file
1#pragma once 2 3#include "ofMain.h" 4#include "ofxOpenCv.h" 5#include "Mouth.h" 6#include "ofxFaceTracker.h" 7 8#include "ofxPd.h" 9#include "msaColor.h" 10 11class Particle { 12public: 13 ofPoint pos; 14 ofPoint vel; 15 float start; 16 float size; 17 msaColor color; 18 19 20 Particle(ofPoint _pos, float _size) { 21 if(img==NULL) { 22 img = new ofImage(); 23 img->loadImage("bulb.png"); 24 img->setAnchorPercent(0.5,0.5); 25 } 26 size = 1 + 12.f*_size + ofRandom(0, 20); 27 color.setHSV(ofRandom(50, 99), 1, 1); 28 pos = _pos; start = pos.x; vel.y = -2; } 29 void draw() { 30 color.setGL(); 31 img->draw(pos.x, pos.y, size, size); 32 glColor4f(1, 1, 1, 1); 33 } 34 void update() { 35 color.a = pos.y/240.f; 36 size += 1; 37 vel.x = -2.5f + 5.f*ofNoise(0.02 + ofGetElapsedTimef()*0.2, 0.3 + start/0.1); 38 pos += vel; 39 } 40 bool isAlive() { 41 if(pos.y < -20) return false; 42 return true; 43 } 44 static ofImage *img; 45}; 46 47 48 49class testApp : public ofBaseApp{ 50 51 public: 52 53 void setup(); 54 void update(); 55 void draw(); 56 57 void keyPressed (int key); 58 void mouseMoved(int x, int y ); 59 void mouseDragged(int x, int y, int button); 60 void mousePressed(int x, int y, int button); 61 void mouseReleased(int x, int y, int button); 62 void windowResized(int w, int h); 63 void audioRequested (float * input, int bufferSize, int nChannels); 64 ofVideoGrabber vidGrabber; 65 66 67 68 vector<Mouth> mouths; 69 70 int WIDTH, HEIGHT; 71 72 ofxPd pd; 73 vector<Particle> particles; 74 75 ofxFaceTracker tracker; 76 77}; 78