diff options
Diffstat (limited to 'liveengineUnmapped/src/layers.h')
| -rwxr-xr-x | liveengineUnmapped/src/layers.h | 97 |
1 files changed, 49 insertions, 48 deletions
diff --git a/liveengineUnmapped/src/layers.h b/liveengineUnmapped/src/layers.h index f8ed650..0ddca29 100755 --- a/liveengineUnmapped/src/layers.h +++ b/liveengineUnmapped/src/layers.h @@ -1,7 +1,7 @@ #ifndef SVGLAYER_H
#define SVGLAYER_H
-#include "ofxSVGTiny.h" +#include "ofxSVGTiny.h"
#include "ofMain.h"
#include "ofxSprite.h"
@@ -12,13 +12,13 @@ class layer layer(string _f) {load(_f);};
virtual ~layer(){};
virtual void load(string _f){};
- virtual void draw(float a,int cx,int cy,float colShift){}; - virtual void draw(float a,unsigned char* controllers,int cx,int cy,bool transparentBlack=false,float colShift=0.0f){ draw(a,cx,cy,colShift);}; - bool getLoaded() {return isLoaded;}; + virtual void draw(float a,int cx,int cy,float colShift){};
+ virtual void draw(float a,unsigned char* controllers,int cx,int cy,bool transparentBlack=false,float colShift=0.0f){ draw(a,cx,cy,colShift);};
+ bool getLoaded() {return isLoaded;};
virtual void setNote(int note) {};
string name;
int startNote,endNote;
- protected: + protected:
bool isLoaded;
private:
@@ -31,31 +31,31 @@ class svglayer: public layer svglayer(string _f);
virtual ~svglayer();
void load(string _f);
- void draw(float a,int cx,int cy,float colShift); + void draw(float a,int cx,int cy,float colShift);
void draw(float a,unsigned char* controllers,int cx,int cy,bool transparentBlack=false,float colShift=0.0f);
void getCentre(int cx,int cy);
protected:
private:
- ofxSVGTiny svg; - vector <ofColor> fills; - vector <ofColor> strokes; + ofxSVGTiny svg;
+ vector <ofColor> fills;
+ vector <ofColor> strokes;
float xo,yo;
};
- -class sunkenSprite: public ofxSprite { - public: +
+class sunkenSprite: public ofxSprite {
+ public:
float playhead,frameRate;
- void setFrameRate(float frameRate) { this->frameRate = frameRate;}; - void play() { - startTime=ofGetElapsedTimef(); - ofxSprite::play(); - } - void update() { + void setFrameRate(float frameRate) { this->frameRate = frameRate;};
+ void play() {
+ startTime=ofGetElapsedTimef();
+ ofxSprite::play();
+ }
+ void update() {
if (!getIsPlaying()) return;
- playhead=fmod(speed * frameRate * (ofGetElapsedTimef()-startTime),(float)getTotalFrames()); - ofxSprite::setCurrentFrame(playhead); - - } + playhead=fmod(speed * frameRate * (ofGetElapsedTimef()-startTime),(float)getTotalFrames());
+ ofxSprite::setCurrentFrame(playhead);
+
+ }
void setCurrentFrame(float frame) {
//this idea doesn't work - fucks up when frameRate is 0 -
//need to rethink
@@ -64,7 +64,7 @@ class sunkenSprite: public ofxSprite { //this still might not be not entirely correct
if (frameRate>0) startTime-=(frame-pos) / ((float)(frameRate * speed ));
//printf("sunkensprite setting frame %i of %i\n",(int)frame,getTotalFrames());
- //printf("1 checking frame %i of %i\n",(int)frame,getTotalFrames()); + //printf("1 checking frame %i of %i\n",(int)frame,getTotalFrames());
ofxSprite::setCurrentFrame(frame);
/*
pos = frame;
@@ -75,28 +75,29 @@ class sunkenSprite: public ofxSprite { while (pos>=totalFrames) pos -= totalFrames;
} else { pos = totalFrames-.00001f; isPlaying=false; }
printf("set movie frame %i of %i\n",(int)pos,totalFrames);
- */ - } - void draw(int x,int y,int w,int h) { - - int f=playhead; - float fr=fmod(playhead,1.0); - ofSetColor(255,255,255,(1.0-fr)*255); - //not always? - getImageAtFrame(f).setUseTexture(true); + */
+ }
+ void draw(int x,int y,int w,int h) {
+
+ int f=playhead;
+ float fr=fmod(playhead,1.0);
+ ofSetColor(255,255,255,(1.0-fr)*255);
+ //not always?
+ getImageAtFrame(f).setUseTexture(true);
getImageAtFrame(f).reloadTexture();
- getImageAtFrame(f).draw(x,y,w,h); + getImageAtFrame(f).draw(x,y,w,h);
ofSetColor(255,255,255,fr*255);
- f=(f+1)%getTotalFrames(); + f=(f+1)%getTotalFrames();
getImageAtFrame(f).setUseTexture(true);
getImageAtFrame(f).reloadTexture();
- getImageAtFrame(f).draw(x,y,w,h); - } - - private: - float startTime; - -}; + getImageAtFrame(f).draw(x,y,w,h);
+ }
+
+ private:
+ float startTime;
+ float speed,pos; //will this override the base class speed correctly?
+
+};
class imglayer: public layer
{
@@ -105,14 +106,14 @@ class imglayer: public layer imglayer(string _f,int _frames=1,int _start=1,float _rate=0,int note=0,int endnote=0);
virtual ~imglayer();
void load(string _filename,int _frames=1,int _start=1,float _rate=0.0,int note=0,int endnote=0);
- void draw(float a,int cx,int cy,float colShift); + void draw(float a,int cx,int cy,float colShift);
void draw(float a,unsigned char* controllers,int cx,int cy,bool transparentBlack,float colShift);
void setNote(int n);
protected:
private:
sunkenSprite sprite;
-}; - +};
+
class videolayer: public layer
{
public:
@@ -120,11 +121,11 @@ class videolayer: public layer videolayer(string _f,int n,int e,float s);
virtual ~videolayer();
void load(string _f);
- void draw(float a,int cx,int cy,float colShift); - void draw(float a,unsigned char* controllers,int cx,int cy,bool transparentBlack,float colShift); - void setNote(int n); + void draw(float a,int cx,int cy,float colShift);
+ void draw(float a,unsigned char* controllers,int cx,int cy,bool transparentBlack,float colShift);
+ void setNote(int n);
protected:
- private: + private:
float speed;
ofVideoPlayer mov;
};
|
