使用 HTML 画布绘制一系列旋转线
我想
100
从由一组角度和长度(50 和 、90 和 20、90 和 30 等..)
有什么想法吗?
I want to draw a polyline like this
from an array consisting of sets of angles and lengths (50 and 100, 90 and 20, 90 and 30 etc..)
Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这是一个困难的......
例如角度和角度的物体阵列lengths:
以下绘制方法将从前一个数组中绘制线条,
您可以在画布元素
编辑后调用绘制:
尝试将绘制函数更改为此,
that was a hard one ...
e.g array of objects of angle & lengths:
the following draw method will draw the lines from the previous array,
you can call the draw after the canvas element
EDIT:
try changing draw function to this,
我遇到了与 Morten J 类似的问题,并尝试了 Shlomi Komemi 的第二个绘图函数,它工作得很好......但仅限于他给出的仅具有 90° 倍数的数组。
然而,如果你尝试 30°,你会发现有些不对劲,因为画的是直角。
我发现这是因为angle和arr[i].angle相加了3次。
这是该函数的更正版本:
应该可以工作(但我猜 Morten 3 年后并不关心......)。
I had a similar problem as Morten J and tried Shlomi Komemi's second draw function and it works fine ... but only for the Array he gave with only multiples of 90°.
However, if you try 30° you will notice that something is wrong because a right angle is drawn.
I figured out that the reason for this is that angle and arr[i].angle are summed up 3 times.
Here is the corrected version of the function:
That should work (but I guess the Morten does not care after 3 years...).