첨부 실행 코드는 나눔고딕코딩 폰트를 사용합니다.
유용한 소스 코드가 있으면 icodebroker@naver.com으로 보내주시면 감사합니다.
블로그 자료는 자유롭게 사용하세요.

■ 별 그리기

------------------------------------------------------------------------------------------------------------------------

using System;

using System.Drawing;

 

#region 별 그리기 - DrawStar(graphics, brush, radius, centerX, centerY)

 

/// <summary>

/// 별 그리기

/// </summary>

/// <param name="graphics">그래픽스</param>

/// <param name="brush">브러시</param>

/// <param name="radius">반경</param>

/// <param name="centerX">중심점 X</param>

/// <param name="centerY">중심점 Y</param>

public void DrawStar(Graphics graphics, Brush brush, float radius, float centerX, float centerY)

{

    float sin36   = (float)Math.Sin(36.0 * Math.PI / 180.0);

    float sin72   = (float)Math.Sin(72.0 * Math.PI / 180.0);

    float cos36   = (float)Math.Cos(36.0 * Math.PI / 180.0);

    float cos72   = (float)Math.Cos(72.0 * Math.PI / 180.0);

    float radius2 = radius * cos72 / cos36;

 

    PointF[] pointArray = new PointF[10];

 

    pointArray[0] = new PointF(centerX                  , centerY - radius         );

    pointArray[1] = new PointF(centerX + radius2 * sin36, centerY - radius2 * cos36);

    pointArray[2] = new PointF(centerX + radius  * sin72, centerY - radius  * cos72);

    pointArray[3] = new PointF(centerX + radius2 * sin72, centerY + radius2 * cos72);

    pointArray[4] = new PointF(centerX + radius  * sin36, centerY + radius  * cos36);

    pointArray[5] = new PointF(centerX                  , centerY + radius2        );

    pointArray[6] = new PointF(centerX - radius  * sin36, centerY + radius  * cos36);

    pointArray[7] = new PointF(centerX - radius2 * sin72, centerY + radius2 * cos72);

    pointArray[8] = new PointF(centerX - radius  * sin72, centerY - radius  * cos72);

    pointArray[9] = new PointF(centerX - radius2 * sin36, centerY - radius2 * cos36);

 

    graphics.FillPolygon(brush, pointArray);

}

 

#endregion

------------------------------------------------------------------------------------------------------------------------

Posted by 사용자 icodebroker

댓글을 달아 주세요