【发布时间】:2020-04-01 08:24:23
【问题描述】:
所以我快结束了。 我整天都在研究如何做到这一点。 绘制一条从一个点到另一个点的路径(动画)。 我已经在 Matrix 上尝试过,但结果只是转向了我的整个路径。
这是我的项目的图片: my project
我的目标是绘制一条从一个圆圈到另一个圆圈的动画路径。
代码:
public void init(@Nullable AttributeSet attr) {
circle = new Paint();
circle.setColor(Color.GREEN);
circle.setStyle(Paint.Style.FILL);
circle.setAntiAlias(true);
line = new Paint();
line.setColor(Color.GREEN);
line.setStyle(Paint.Style.STROKE);
line.setStrokeWidth(10);
line.setAntiAlias(true);
Collections.addAll(height, 100, 20, 50, 40, 70, 10, 50); // in percent
System.out.println(height.size() + " this is the size");
}
@Override
protected void onDraw(Canvas canvas) {
float y = getHeight() / 20 * 14;
float x = getWidth() / 8;
float radius = (canvas.getWidth() * canvas.getHeight()) / 40940;
for (int c = 1; c < 8; c++) {
System.out.println("at " + c);
canvas.drawCircle(x * c, y - ((getHeight() / 20) * (height.get(c - 1) / 10)), radius, circle);
points.add(new PointF(x * c, (y - ((getHeight() / 20) * (height.get(c - 1) / 10)))));
}
}
请帮忙,
谢谢
【问题讨论】: