From ee9819390008b29ee2cfc1bc45fac3e3b1530529 Mon Sep 17 00:00:00 2001 From: tim Date: Fri, 18 Apr 2014 03:15:31 +0100 Subject: phew --- liveengineUnmapped/src/layers.cpp | 152 +++++++++++++++++++------------------- 1 file changed, 76 insertions(+), 76 deletions(-) (limited to 'liveengineUnmapped/src/layers.cpp') diff --git a/liveengineUnmapped/src/layers.cpp b/liveengineUnmapped/src/layers.cpp index a0fb213..36de3b1 100755 --- a/liveengineUnmapped/src/layers.cpp +++ b/liveengineUnmapped/src/layers.cpp @@ -1,60 +1,60 @@ #include "layers.h" -svglayer::svglayer() { - xo=0;yo=0; +svglayer::svglayer() { + xo=0;yo=0; } svglayer::svglayer(string _f) { load(_f); } -void svglayer::load(string _f){ +void svglayer::load(string _f){ //check if files exits svg.load(_f); printf("%s: %i paths\n",_f.c_str(),svg.getNumPath()); - for (int i=0;i0); } void svglayer::getCentre(int cx,int cy) { if (svg.getNumPath()>0) { - xo=(cx-svg.getWidth())/2; - yo=(cy-svg.getHeight())/2; + xo=cx-256; //(cx-svg.getWidth())/2; + yo=cy-256; //(cy-svg.getHeight())/2; } } void svglayer::draw(float a,int cx,int cy,float colShift) { - getCentre(cx,cy); + getCentre(cx,cy); for (int i=0;i0.0f) { c.setHue(fmod(c.getHue()+colShift,255.0f)); //printf ("shift from %f to %f\n",c.getHue(),c.getHue()+colShift); - } - svg.getPathAt(i).setFillColor(c); - svg.getPathAt(i).draw(xo,yo); + } + svg.getPathAt(i).setFillColor(c); + svg.getPathAt(i).draw(xo,yo); } -} -/* +} +/* void svglayer::draw(float a,unsigned char* controllers,int cx,int cy,bool transparentBlack,float colShift) { - getCentre(cx,cy); + getCentre(cx,cy); //draw layers tinted by controllers - for (int i=0;i0.1) { - svg.getPathAt(i).draw(xo,yo); - } + for (int i=0;i0.1) { + svg.getPathAt(i).draw(xo,yo); + } } } */ @@ -65,42 +65,42 @@ void svglayer::draw(float a,unsigned char* controllers,int cx,int cy,bool transp float layerspercontroller=((float)svg.getNumPath())/6.0f; for (int i=0;i<6;i++) { - //for (int j=(int)((i+1)*layerspercontroller)-1;j>(int)(i*layerspercontroller);j--) { + //for (int j=(int)((i+1)*layerspercontroller)-1;j>(int)(i*layerspercontroller);j--) { for (int j=(int)(i*layerspercontroller);j<(int)((i+1)*layerspercontroller);j++) { svg.getPathAt(j).setFillColor(fills[j]*a*(((float)controllers[5-i])/127.0f)); //try to reverse order of these if (!transparentBlack||((a*controllers[5-i])/127.0f)>0.1) { svg.getPathAt(j).draw(xo,yo); } } - } + } //printf("counted %i layers of %i\n",(int)(6*layerspercontroller),svg.getNumPath()); -} +} svglayer::~svglayer() { //dtor -} - -//------------------------------------------------------------------------ -imglayer::imglayer() { - //sprite.setUseTexture(false); +} + +//------------------------------------------------------------------------ +imglayer::imglayer() { + //sprite.setUseTexture(false); } imglayer::imglayer(string _filename,int _frames,int _start,float _rate,int n, int e){ load(_filename,_frames,_start,_rate,n,e); } -void imglayer::load(string _filename,int _frames,int _start,float _rate,int n, int e){ - startNote=n; +void imglayer::load(string _filename,int _frames,int _start,float _rate,int n, int e){ + startNote=n; endNote=e; sprite.load(_filename,_frames,_start); sprite.setFrameRate(_rate); } - -void imglayer::draw(float a,int cx,int cy,float colShift) { + +void imglayer::draw(float a,int cx,int cy,float colShift) { //if (sprite.isAllocated()) if (!sprite.isUsingTexture()) sprite.setUseTexture(true); //has to be done from the main thread? still doesn't work - + sprite.update(); int x,y,w,h; if ((((float)cx)/cy)<(((float)sprite.getWidth())/sprite.getHeight())){ @@ -115,25 +115,25 @@ void imglayer::draw(float a,int cx,int cy,float colShift) { w=((float)cy)*(((float)sprite.getWidth())/sprite.getHeight()); x=(cx-w)/2; } - ofEnableAlphaBlending(); + ofEnableAlphaBlending(); sprite.draw(x,y,w,h); ofDisableAlphaBlending(); -} - -void imglayer::draw(float a,unsigned char* controllers,int cx,int cy,bool transparentBlack=false,float colShift=0.0f) { +} + +void imglayer::draw(float a,unsigned char* controllers,int cx,int cy,bool transparentBlack=false,float colShift=0.0f) { imglayer::draw(a,cx,cy,colShift); } void imglayer::setNote(int note) -{ - //is called rerpeatedly no startNote,endNote +{ + //is called rerpeatedly no startNote,endNote //printf("note %i (%i - %i)\n",note,startNote,endNote); if ((startNote<=note)&&(endNote>=note)) { if (!sprite.getIsPlaying()) { sprite.play(); - } + } //printf("triggered frame %i of %i\n",(int)(((((float)note-startNote)/((float)endNote-startNote)))*sprite.getTotalFrames()),sprite.getTotalFrames()); sprite.setCurrentFrame((int)(((((float)note-startNote)/((float)endNote-startNote)))*sprite.getTotalFrames())); //printf("movie %i (%i - %i) frame: %i\n",note,startNote,endNote,(int)(((((float)note-startNote)/((float)endNote-startNote)))*mov.getTotalNumFrames())); @@ -144,20 +144,20 @@ void imglayer::setNote(int note) } } -}; +}; imglayer::~imglayer() { //sprite.setUseTexture(false); //free texture -} -//------------------------------------------------------------------------ -videolayer::videolayer() { - //sprite.setUseTexture(false); +} +//------------------------------------------------------------------------ +videolayer::videolayer() { + //sprite.setUseTexture(false); } videolayer::videolayer(string _f,int n,int e,float s) -{ - startNote=n; +{ + startNote=n; endNote=e; speed=s; load(_f); @@ -174,8 +174,8 @@ void videolayer::load(string _f){ printf("%s %s %i bpp\n",success?"loaded":"not loaded",_f.c_str(),success?mov.getPixelsRef().getBytesPerPixel():0); } -void videolayer::draw(float a,int cx,int cy,float colShift) { - if (mov.isPlaying()) { +void videolayer::draw(float a,int cx,int cy,float colShift) { + if (mov.isPlaying()) { mov.update(); //unsigned char *pix=mov.getPixels(); //for (int i=0;i>2)+(pix[i+1]>>1)+(pix[i+2]>>2); @@ -194,34 +194,34 @@ void videolayer::draw(float a,int cx,int cy,float colShift) { } ofEnableAlphaBlending(); mov.draw(x,y,w,h); - ofDisableAlphaBlending(); + ofDisableAlphaBlending(); } -} - -void videolayer::draw(float a,unsigned char* controllers,int cx,int cy,bool transparentBlack=false,float colShift=0.0f) { +} + +void videolayer::draw(float a,unsigned char* controllers,int cx,int cy,bool transparentBlack=false,float colShift=0.0f) { draw(a,cx,cy,colShift); -} - -void videolayer::setNote(int note) +} + +void videolayer::setNote(int note) { - - if ((startNote<=note)&&(endNote>=note)) { + + if ((startNote<=note)&&(endNote>=note)) { if (!mov.isPlaying()) { //printf("starting movie!\n"); mov.setUseTexture(true); mov.play(); mov.setSpeed(speed); - } + } mov.setFrame((int)(((((float)note-startNote)/((float)endNote-startNote)))*mov.getTotalNumFrames())); - //printf("movie %i (%i - %i) frame: %i\n",note,startNote,endNote,(int)(((((float)note-startNote)/((float)endNote-startNote)))*mov.getTotalNumFrames())); - } - else { - if (mov.isPlaying()) { - mov.stop(); - } - } - -}; + //printf("movie %i (%i - %i) frame: %i\n",note,startNote,endNote,(int)(((((float)note-startNote)/((float)endNote-startNote)))*mov.getTotalNumFrames())); + } + else { + if (mov.isPlaying()) { + mov.stop(); + } + } + +}; videolayer::~videolayer() -- cgit v1.2.3