Live Wallpaper动态壁纸开发
2011-07-01 20:50:24 来源:本站整理holder.unlockCanvasAndPost(c);
}
mHandler.removeCallbacks(mDrawPattern);
if (mVisible)
{
mHandler.postDelayed(mDrawPattern, 1000 / 25);
}
}
void drawPattern(Canvas c)
{
c.save();
c.drawColor(0xff000000);
Paint paint = new Paint();
if (mMotion)
{
mFrameCounter++;
if (mHorizontal)
{
int right;
int left;
if (mFrameCounter > mRectFrame.right)
mFrameCounter = 0;
for (int i = 0; i < mRectCount; i++)
{
paint.setColor(rectColor[i]);
right = mColorRectangles[i].right + mFrameCounter;
left = mColorRectangles[i].left + mFrameCounter;
if(right > mRectFrame.right)
{
c.drawRect(left - mRectFrame.right, mColorRectangles[i].top, right - mRectFrame.right, mColorRectangles[i].bottom, paint);
}
if(left < mRectFrame.right)
{
c.drawRect(left, mColorRectangles[i].top, right, mColorRectangles[i].bottom, paint);
}
}
if(mShape.compareToIgnoreCase("smpte") == 0)
{
right =mGradientRect.right + mFrameCounter;
left = mGradientRect.left + mFrameCounter;
if(right > mRectFrame.right)
{
mGradient.setBounds(left - mRectFrame.right, mGradientRect.top, right - mRectFrame.right, mGradientRect.bottom);
mGradient.draw(c);
}
if(left < mRectFrame.right)
{
mGradient.setBounds(left, mGradientRect.top, right, mGradientRect.bottom);
mGradient.draw(c);
}
}
}
else
{
int top;
int bottom;
if (mFrameCounter > mRectFrame.bottom)
mFrameCounter = 0;
for (int i = 0; i < mRectCount; i++)
{
paint.setColor(rectColor[i]);
top = mColorRectangles[i].top + mFrameCounter;
bottom = mColorRectangles[i].bottom + mFrameCounter;
if(bottom > mRectFrame.bottom)
{
c.drawRect(mColorRectangles[i].left, top - mRectFrame.bottom, mColorRectangles[i].right, bottom - mRectFrame.bottom, paint);
}
if(top < mRectFrame.bottom)
{
c.drawRect(mColorRectangles[i].left, top, mColorRectangles[i].right, bottom, paint);
}
}
if(mShape.compareToIgnoreCase("smpte") == 0)
{
top = mGradientRect.top + mFrameCounter;
bottom = mGradientRect.bottom + mFrameCounter;
if(bottom > mRectFrame.bottom)
{
mGradient.setBounds(mGradientRect.left, top - mRectFrame.bottom, mGradientRect.right, bottom - mRectFrame.bottom);
更多精彩
赞助商链接