android动态壁纸---线条(5)
来源:未知 责任编辑:责任编辑 发表时间:2013-12-06 08:44 点击:次
drawLine(c, -400, -400, 400, -400, -400, -400);
drawLine(c, 400, -400, 400, 400, -400, -400);
drawLine(c, 400, 400, 400, 400, 400, -400);
drawLine(c, -400, 400, 400, -400, 400, -400);
c.restore();
}
/*
* Draw a 3 dimensional line on to the screen
*/
void drawLine(Canvas c, int x1, int y1, int z1, int x2, int y2, int z2) {
long now = SystemClock.elapsedRealtime();
float xrot = ((float)(now - mStartTime)) / 1000;
float yrot = (0.5f - mOffset) * 2.0f;
float zrot = 0;
// 3D transformations
// rotation around X-axis
float newy1 = (float)(Math.sin(xrot) * z1 + Math.cos(xrot) * y1);
float newy2 = (float)(Math.sin(xrot) * z2 + Math.cos(xrot) * y2);
float newz1 = (float)(Math.cos(xrot) * z1 - Math.sin(xrot) * y1);
float newz2 = (float)(Math.cos(xrot) * z2 - Math.sin(xrot) * y2);
// rotation around Y-axis
float newx1 = (float)(Math.sin(yrot) * newz1 + Math.cos(yrot) * x1);
float newx2 = (float)(Math.sin(yrot) * newz2 + Math.cos(yrot) * x2);
newz1 = (float)(Math.cos(yrot) * newz1 - Math.sin(yrot) * x1);
newz2 = (float)(Math.cos(yrot) * newz2 - Math.sin(yrot) * x2);
// 3D-to-2D projection
float startX = newx1 / (4 - newz1 / 400);
相关新闻>>
最新推荐更多>>>
- 发表评论
-
- 最新评论 更多>>