我正在尝试使用线条构建一个圆圈。每条线从圆的中心开始,只有圆的半径。使用正弦波和辅助波和圆环,我可以使用正弦和cosign构建圆圈以标记坐标的坐标。 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这样的浮点数是否是有效的厚度。

有帮助吗?

解决方案

我建议将它们描绘成楔子而不是线条,将其复制并粘贴到新的FLA中,以了解我的意思:

var nRadians : Number;

var nradius:数字= 100;

var nx:数字;

var ny:数字;

var先前x:number = nradius;

var先前:number = 0;

//这对我来说是有意义的,但仍然会产生一些差距

var linethickness:数字= 1 +((((nradius * 2) * Math.pi)-360) / 359;

for(var i:int = 0; i <360; i ++){

//将学位转换为弧度。 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.beginFill( Math.random() * 0xFFFFFF );
graphics.moveTo( 0, 0 );
graphics.lineTo( previousX, previousY );
graphics.lineTo( nX, nY );
graphics.lineTo( 0, 0 );
graphics.endFill();
previousX = nX;
previousY = nY;

}

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top