【发布时间】:2010-05-19 10:51:40
【问题描述】:
我正在尝试使用线条构建一个圆圈。每条线都从圆的中心开始,与圆的半径一样长。使用循环以及正弦波和余弦波,我可以使用正弦波和余弦来构建圆来标记lineTo 参数的坐标。
我的问题是lineStyle 的线条粗细参数。我希望线条的末端完美匹配,无论圆的周长有多大,但我无法找出合适的线条粗细方法。
//this is what makes sense to me, but it still creates some gaps
lineThickness = 1 + (((nRadius * 2) * Math.PI) - 360) / 359;
for(var i:int = 0; i < 360; i++)
{
// Convert the degree to radians.
nRadians = i * (Math.PI / 180);
// Calculate the coordinate in which the line should be drawn to.
nX = nRadius * Math.cos(nRadians);
nY = nRadius * Math.sin(nRadians);
// Create and drawn the line.
graphics.lineStyle(lineThickness, 0, 1, false, LineScaleMode.NORMAL, CapsStyle.NONE);
graphics.moveTo(0, 0);
graphics.lineTo(nX, nY);
}
为了使线条的末端在圆圈圆周处相交,没有任何间隙,我需要加宽线条以填充剩余的空间。对我来说有意义但不起作用的是从周长中减去 360,然后将该数字除以线之间的空槽数量(即 359)并将该数字加上 1 的厚度。
我担心的是lineStyle 厚度参数是Number,但似乎只取 0 到 255 之间的值,所以我不确定像 1.354 这样的浮点数是否是有效的厚度。
【问题讨论】:
-
我想我理解你想要达到的目标,但我真的不明白为什么? (我只是好奇)
-
这样我可以访问每行的颜色值
标签: actionscript-3 graphics thickness linestyle