HTML5 Canvas(或替代方案):移动线条来模拟行星上的经络
这是我第一次涉足 HTML5 画布,我拥有 jQuery 和 Javascript 的工作知识。 我正在尝试用它创建“旋转地球”效果。 这个想法是让一个圆圈和经络在其上“旋转”,以产生旋转地球仪的效果。
我已经画了圆,现在我正在尝试创建从右侧开始的线(沿着圆的曲线),向中心移动,向上拉直(在中间它们是直的)并沿着圆上的反曲率向左,以圆圈结束。
我正在尝试使用 HTML5 画布和 jQuery 来完成此操作,但我不确定从哪里开始...我应该创建一个弧线,然后尝试为其设置动画吗?
我什至想知道画布是否是正确的工具,或者我是否应该使用其他工具。
欢迎任何建议!
塞巴斯蒂安
This is my firs excursion on the HTML5 canvas, I have working knowledge of jQuery and Javascript.
I'm trying to create a "spinning globe" effect with it.
The idea is to have a circle and meridians "spinning" on it, to give the effect of a rotating globe.
I've drawn the circle and now I'm trying to create lines that start from the right (following the curve of the circle), move towards the centre straightnening up (in the middle they are straight) and follow the inverse curvature on the left, ending with the circle.
I'm trying to do this with the HTML5 canvas and jQuery but I'm not sure of where to start... should I create an arc and then try to animate it?
I'm even wondering if the canvas is the right tool or if I should use anything else.
Any suggestion is welcome!
Sebastian
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用二次贝塞尔曲线,它基本上只是一条具有起点、终点和中间“控制点”的曲线,这是您在地球旋转时想要更改的内容。在这种情况下,您的所有线都将分别在“地球”的北极和南极开始和结束。例如,要制作以下线条之一:
当然,您还必须考虑如何在每一帧之后清除线条。
请参阅:Canvas 元素 API,复杂路径
You could use a quadratic bezier curve, which is basically just a curve with a start point, an end point, and a "control point" in the middle, which is what you would want to change as the globe spins. In this case, all of your lines would start and end at the north and south poles, respectively, of your "globe". For example, to make one of these lines:
You would also have to take in to account how you will clear the lines after each frame, of course.
See: The Canvas element API, Complex Paths
这就是我得到的,没有时间继续进行: http://jsfiddle.net/Z6h3Z/< /a>
我使用贝塞尔曲线,其中两个控制点位于以极点为中心的椭圆弧中。
我遇到的问题是沿弧线分布点,以便看起来更真实。
This is what I got, didn't have the time to proceed any further: http://jsfiddle.net/Z6h3Z/
I use bezier curves where the two control points are in a sort of oval arc centered at the poles.
What I got stuck at is the distribution of points along the arc to look more realistic.