본문 바로가기
프로그래밍/App 개발

[Xamarin] Draw Arc with SkiaSharp

by 엽기토기 2021. 6. 14.
반응형

https://docs.microsoft.com/ko-kr/xamarin/xamarin-forms/user-interface/graphics/skiasharp/curves/arcs

 

원호를 그리는 3가지 방법 - Xamarin

이 문서에서는 SkiaSharp를 사용 하 여 세 가지 방법으로 원호를 정의 하는 방법을 설명 하 고 샘플 코드를 사용 하 여이를 보여 줍니다.

docs.microsoft.com

Start Angle : X축 0도 기준 시작각도

Sweep Angle : 그리고자 하는 호의 각도 (StartAngle를 시작으로 SweepAngle 만큼 호를 그림)

코드 식으로 나타내면,

var _emptyArcAngle = 60;
StartAngle = 90 + _emptyArcAngle / 2;
SweepAngle = 360 - _emptyArcAngle;

emptyArcAngle 은 그리지 않는 호의 각도.

DrawCircle(info, canvas, backpaint, SweepAngle);

...


private void DrawCircle(SKImageInfo info, SKCanvas canvas, SKPaint paint, float angle)
{
  var size = Math.Min(info.Width, info.Height);

  using (var path = new SKPath())
  {
    var rect = new SKRect(
    StrokeWidth,
    StrokeWidth,
    size - StrokeWidth,
    size - StrokeWidth);

    path.AddArc(rect, StartAngle, angle);

    canvas.DrawPath(path, paint);
  }
}

 

반응형