첨부 실행 코드는 나눔고딕코딩 폰트를 사용합니다.
본 블로그는 광고를 포함하고 있습니다.
광고 클릭에서 발생하는 수익금은 모두 블로그 콘텐츠 향상을 위해 쓰여집니다.

728x90
반응형
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
728x90
반응형
그리드형(광고전용)
Posted by 사용자 icodebroker

댓글을 달아 주세요