From 796d647fd38f7cf01cb70bbb0700b75427e42d55 Mon Sep 17 00:00:00 2001 From: Tim Redfern Date: Sun, 28 Oct 2012 17:40:19 +0000 Subject: starting to build kinect addition --- liveengineUnmapped/src/layers.cpp | 115 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 115 insertions(+) create mode 100755 liveengineUnmapped/src/layers.cpp (limited to 'liveengineUnmapped/src/layers.cpp') diff --git a/liveengineUnmapped/src/layers.cpp b/liveengineUnmapped/src/layers.cpp new file mode 100755 index 0000000..4ac0c59 --- /dev/null +++ b/liveengineUnmapped/src/layers.cpp @@ -0,0 +1,115 @@ +#include "layers.h" + +svglayer::svglayer() { + xo=0;yo=0; +} +svglayer::svglayer(string _f) +{ + load(_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; + } +} + +void svglayer::draw(float a,int cx,int cy,float colShift) { + 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); + } +} +/* +void svglayer::draw(float a,unsigned char* controllers,int cx,int cy,bool transparentBlack,float colShift) { + getCentre(cx,cy); + //draw layers tinted by controllers + for (int i=0;i0.1) { + 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); + //draw layers grouped by controllers + float layerspercontroller=((float)svg.getNumPath())/6.0f; + + for (int i=0;i<6;i++) { + for (int j=(int)(i*layerspercontroller);j<(int)((i+1)*layerspercontroller);j++) { + svg.getPathAt(j).setFillColor(fills[i]*a*controllers[i]); + if (!transparentBlack||((a*controllers[i])/127.0)>0.1) { + svg.getPathAt(j).draw(xo,yo); + } + } + } +} + + +svglayer::~svglayer() +{ + //dtor +} + +imglayer::imglayer() { + //img.setUseTexture(false); +} +imglayer::imglayer(string _f) +{ + load(_f); +} + +void imglayer::load(string _f){ + bool success=img.loadImage(_f); + printf("%s\n",success?"loaded":"not loaded"); +} + +/* +WTF is going on with the image drawing + + +*/ +void imglayer::draw(float a,int cx,int cy,float colShift) { + //if (img.isAllocated()) if (!img.isUsingTexture()) img.setUseTexture(true); //has to be done from the main thread? still doesn't work + img.draw(0,0,ofGetWidth(),ofGetHeight()); + printf("drawing %f\n",ofGetElapsedTimef()); +} + +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); +} + + +imglayer::~imglayer() +{ + //img.setUseTexture(false); //free texture +} -- cgit v1.2.3