Live Wallpaper动态壁纸开发
2011-07-01 20:50:24 来源:本站整理mGradient.draw(c);
}
if(top < mRectFrame.bottom)
{
mGradient.setBounds(mGradientRect.left, top, mGradientRect.right, bottom);
mGradient.draw(c);
}
}
}
}
else
{
for (int i = 0; i < mRectCount; i++)
{
paint.setColor(rectColor[i]);
c.drawRect(mColorRectangles[i], paint);
}
if(mShape.compareToIgnoreCase("smpte") == 0)
{
mGradient.setBounds(mGradientRect);
mGradient.draw(c);
}
}
c.restore();
}
void drawTouchPoint(Canvas c)
{
if (mTouchX >= 0 && mTouchY >= 0)
{
c.drawCircle(mTouchX, mTouchY, 80, mPaint);
}
}
void initFrameParams()
{
DisplayMetrics metrics = new DisplayMetrics();
Display display = ((WindowManager) getSystemService(WINDOW_SERVICE)).getDefaultDisplay();
display.getMetrics(metrics);
mRectFrame = new Rect(0, 0, metrics.widthPixels, metrics.heightPixels);
int rotation = display.getOrientation();
if(rotation == Surface.ROTATION_0 || rotation == Surface.ROTATION_180)
mHorizontal = false;
else
mHorizontal = true;
System.out.println("mHorizontal "+mHorizontal);
System.out.println("mShape "+mShape);
if(mShape.compareToIgnoreCase("smpte") == 0)
{
System.out.println("mShape == smpte");
CreateSmpte();
}
else if(mShape.compareToIgnoreCase("bars") == 0)
{
System.out.println("mShape == bars");
CreateBars();
}
else
{
System.out.println("mShape == ebu");
CreateEbu();
}
}
private void CreateSmpte()
{
if(mHorizontal)
{
int topHeight = mRectFrame.bottom * 7 / 12;
int bottomHeight = mRectFrame.bottom * 3 / 4;
int wideColumnWidth = mRectFrame.right / 8;
int narrowColumnWidth = mRectFrame.right * 3 / 28;
mColorRectangles[0] = new Rect(0, 0, wideColumnWidth, topHeight);
for (int i = 1; i < 8; i++)
{
mColorRectangles[i] = new Rect(mColorRectangles[i - 1].right, 0, mColorRectangles[i - 1].right + narrowColumnWidth, topHeight);
}
mColorRectangles[8] = new Rect(mColorRectangles[7].right, 0, mRectFrame.right, topHeight);
for (int i = 0; i < 2; i++)
{
int middleTop = mRectFrame.bottom * (7 + i) / 12;
int middleBottom = mRectFrame.bottom * (8 + i) / 12;
mColorRectangles[i + 9] = new Rect(0, middleTop, wideColumnWidth, middleBottom);
mColorRectangles[i + 11] = new Rect(wideColumnWidth, middleTop, narrowColumnWidth + wideColumnWidth, middleBottom);
mColorRectangles[i + 13] = new Rect(narrowColumnWidth * 7 + wideColumnWidth, middleTop, mRectFrame.right, middleBottom);
}
mColorRectangles[15] = new Rect(narrowColumnWidth + wideColumnWidth, topHeight, narrowColumnWidth * 7 + wideColumnWidth, mRectFrame.bottom * 8 / 12);
更多精彩
赞助商链接