0

線を使って円を作ろうとしています。各線は円の中心から始まり、円の半径と同じ長さです。サイン波とコサイン波とともにループを使用して、パラメーターの座標をマークするためにサイン波とコサインを使用して円を作成でき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のような浮動小数点数が有効な厚さであるかどうかはわかりません。

4

1 に答える 1

1

線ではなくくさびとして描画し、これをコピーして新しいFLAに貼り付けて、意味を確認することをお勧めします。

var nRadians : Number;

var nRadius : Number = 100;

var nX : Number;

var nY : Number;

var previousX : Number = nRadius;

var previousY : Number = 0;

//this is what makes sense to me, but it still creates some gaps

var lineThickness : Number = 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.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;

}

于 2010-05-19T13:16:17.420 に答える