void RenderBitmap(const Rect &inSrc, int inX, int inY) { DrawElement &e = mBitmapBuffer.mElements[0]; mBitmapBuffer.mArray.resize( (e.mCount+6) * e.mStride ); UserPoint *p = (UserPoint *)&mBitmapBuffer.mArray[e.mCount*e.mStride]; e.mCount+=6; UserPoint corners[4]; UserPoint tex[4]; for(int i=0;i<4;i++) { corners[i] = UserPoint(inX + ((i&1)?inSrc.w:0), inY + ((i>1)?inSrc.h:0) ); tex[i] = mBitmapTexture->PixelToTex(UserPoint(inSrc.x + ((i&1)?inSrc.w:0), inSrc.y + ((i>1)?inSrc.h:0) )); } *p++ = corners[0]; *p++ = tex[0]; *p++ = corners[1]; *p++ = tex[1]; *p++ = corners[2]; *p++ = tex[2]; *p++ = corners[1]; *p++ = tex[1]; *p++ = corners[2]; *p++ = tex[2]; *p++ = corners[3]; *p++ = tex[3]; }
void Graphics::clear() { mFillJob.clear(); mLineJob.clear(); mTileJob.clear(); // clear jobs for(int i=0;i<mJobs.size();i++) mJobs[i].clear(); mJobs.resize(0); if (mHardwareData) { delete mHardwareData; mHardwareData = 0; } mPathData->clear(); mExtent0 = Extent2DF(); mRotation0 = 0; mBuiltHardware = 0; mMeasuredJobs = 0; mCursor = UserPoint(0,0); mVersion++; }
void Graphics::clear(bool inForceFreeHardware) { mFillJob.clear(); mLineJob.clear(); mTileJob.clear(); // clear jobs for(int i=0;i<mJobs.size();i++) mJobs[i].clear(); mJobs.resize(0); if (mHardwareData) { if (inForceFreeHardware || mClearCount<4) { delete mHardwareData; mHardwareData = 0; } else mHardwareData->clear(); if (!inForceFreeHardware) mClearCount++; } mPathData->clear(); mExtent0 = Extent2DF(); mRotation0 = 0; mBuiltHardware = 0; mMeasuredJobs = 0; mCursor = UserPoint(0,0); OnChanged(); }
void Graphics::arcTo(float cx, float cy, float x, float y) { if ( (mFillJob.mFill && mFillJob.mCommand0==mPathData->commands.size()) || (mLineJob.mStroke && mLineJob.mCommand0==mPathData->commands.size()) ) mPathData->initPosition(mCursor); mPathData->arcTo(cx,cy,x,y); mCursor = UserPoint(x,y); OnChanged(); }
void Graphics::lineTo(float x, float y) { if ( (mFillJob.mFill && mFillJob.mCommand0==mPathData->commands.size()) || (mLineJob.mStroke && mLineJob.mCommand0==mPathData->commands.size()) ) mPathData->initPosition(mCursor); mPathData->lineTo(x,y); mCursor = UserPoint(x,y); mVersion++; }
Graphics::Graphics(bool inInitRef) : Object(inInitRef) { mRotation0 = 0; mCursor = UserPoint(0,0); mHardwareData = 0; mPathData = new GraphicsPath; mBuiltHardware = 0; mTileJob.mIsTileJob = true; mMeasuredJobs = 0; mVersion = 0; }
UserPoint Matrix::ApplyInverse(const UserPoint &inPoint) const { double det = m00*m11 - m01*m10; if (det==0) return inPoint; det = 1.0/det; double x = inPoint.x - mtx; double y = inPoint.y - mty; return UserPoint( (m11*x - m01*y)*det, (-m10*x + m00*y)*det ); }
Graphics::Graphics(DisplayObject *inOwner,bool inInitRef) : Object(inInitRef) { mRotation0 = 0; mCursor = UserPoint(0,0); mHardwareData = 0; mPathData = new GraphicsPath; mBuiltHardware = 0; mTileJob.mIsTileJob = true; mMeasuredJobs = 0; mClearCount = 0; mVersion = 0; mOwner = inOwner; }
void UserTracker::addUser(int nId, ci::Vec3f position) { UserPoint newUser = UserPoint(); newUser.id = nId; newUser.position = position; newUser.prevPosition = position; //for(int i = 0; i<userPoints.size();++i) //{ if(userPoints.size() < 1) { userPoints.push_back(newUser); } // } cout << userPoints.size() << endl; }
void Graphics::curveTo(float cx, float cy, float x, float y) { if ( (mFillJob.mFill && mFillJob.mCommand0==mPathData->commands.size()) || (mLineJob.mStroke && mLineJob.mCommand0==mPathData->commands.size()) ) mPathData->initPosition(mCursor); if ( (fabs(mCursor.x-cx)<EPSILON && fabs(mCursor.y-cy)<EPSILON) || (fabs(x-cx)<EPSILON && fabs(y-cy)<EPSILON) ) { mPathData->lineTo(x,y); } else mPathData->curveTo(cx,cy,x,y); mCursor = UserPoint(x,y); OnChanged(); }
void Graphics::moveTo(float x, float y) { mPathData->moveTo(x,y); mCursor = UserPoint(x,y); OnChanged(); }
UserPoint PixelToTex(const UserPoint &inPixels) { return UserPoint(inPixels.x/width, inPixels.y/height); }
void Graphics::moveTo(float x, float y) { mPathData->moveTo(x,y); mCursor = UserPoint(x,y); mVersion++; }
UserPoint Matrix::Apply(float inX,float inY) const { return UserPoint( inX*m00 + inY*m01 + mtx, inX*m10 + inY*m11 + mty ); }