Android,沿路径移动位图?
我想知道是否可以从路径中选择坐标来随着时间的推移绘制位图,例如,我有一张太阳的图像,我想随着时间的推移沿着弧形路径移动它。
有没有什么方法可以定义这样的路径,然后沿着它移动,这样我就不必进行数学计算?
谢谢。
I would like to know if it's possible to select coordinates from a path to draw a bitmap over time, for example, I have an image of a sun, and I would like to move it, over time, along an arc path.
Is there some way to define a path like this and then move along it, so that I don't have to calculate it mathematically?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
是的,可以沿着路径移动图像。我将提供简单的解决方案来展示原理。以下代码将移动和旋转您的图像。如果不需要旋转,请删除 TANGENT_MATRIX_FLAG 标志。
Yes, it's possible to move image along path. I will provide simple solution to show the principle. The following code will move and rotate your image. If you don't need rotation remove the TANGENT_MATRIX_FLAG flag.
以下是我使用的动画师:
目的:沿路径“路径”移动视图“视图”
v21+:
v11+:
类似要求: https:// /stackoverflow.com/a/30254715/4344057
Here are the animators I use:
Purpose: Move View "view" along Path "path"
v21+:
v11+:
Similar requirement to: https://stackoverflow.com/a/30254715/4344057
我正在考虑一种解决方案:
如果您的弧具有这种形状(意味着小于半个圆并且水平放置),那么您可以迭代 x 值,并为此 x 获取路径上的 y。然后将位图移动到该位置。
I'm thinking of one solution:
If your arc has this kind of shape (meaning less than half a circle and positioned horizontaly) then you could iterate the x value and for that x get the y that's on the path. Then move your bitmap to that position.