728x90
반응형
728x170
▶ GraphicsDrawable.cs
namespace TestProject;
/// <summary>
/// 그래픽스 그리기 가능형
/// </summary>
public class GraphicsDrawable : IDrawable
{
//////////////////////////////////////////////////////////////////////////////////////////////////// Method
////////////////////////////////////////////////////////////////////////////////////////// Public
#region 그리기 - Draw(canvas, dirtyRectangle)
/// <summary>
/// 그리기
/// </summary>
/// <param name="canvas">캔버스</param>
/// <param name="dirtyRectangle">더티 사각형</param>
public void Draw(ICanvas canvas, RectF dirtyRectangle)
{
PointF centerPoint = new PointF(dirtyRectangle.Center.X, dirtyRectangle.Center.Y);
float radius = Math.Min(dirtyRectangle.Width, dirtyRectangle.Height) / 4;
float distance = 0.8f * radius;
PointF centerPoint1 = new PointF
(
distance * (float)Math.Cos(9 * Math.PI / 6) + centerPoint.X,
distance * (float)Math.Sin(9 * Math.PI / 6) + centerPoint.Y
);
PointF centerPoint2 = new PointF
(
distance * (float)Math.Cos(1 * Math.PI / 6) + centerPoint.X,
distance * (float)Math.Sin(1 * Math.PI / 6) + centerPoint.Y
);
PointF centerPoint3 = new PointF
(
distance * (float)Math.Cos(5 * Math.PI / 6) + centerPoint.X,
distance * (float)Math.Sin(5 * Math.PI / 6) + centerPoint.Y
);
canvas.BlendMode = BlendMode.Multiply;
canvas.FillColor = Colors.Cyan;
canvas.FillCircle(centerPoint1, radius);
canvas.FillColor = Colors.Magenta;
canvas.FillCircle(centerPoint2, radius);
canvas.FillColor = Colors.Yellow;
canvas.FillCircle(centerPoint3, radius);
}
#endregion
}
728x90
▶ MainPage.xaml
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage x:Class="TestProject.MainPage"
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:TestProject">
<ContentPage.Resources>
<local:GraphicsDrawable x:Key="GraphicsDrawableKey" />
</ContentPage.Resources>
<GraphicsView
HorizontalOptions="Center"
VerticalOptions="Center"
WidthRequest="350"
HeightRequest="350"
Drawable="{StaticResource GraphicsDrawableKey}" />
</ContentPage>
728x90
반응형
그리드형(광고전용)
'C# > MAUI' 카테고리의 다른 글
[C#/MAUI/.NET6] REST WEB API 서비스 사용하기 (ANDROID) (UWP) (0) | 2022.07.12 |
---|---|
[C#/MAUI/.NET6] Shell 엘리먼트 : 태양 일출/일몰 및 달 위상 정보 조회하기 (0) | 2022.07.09 |
[C#/MAUI/.NET6] Connectivity 클래스 : ConnectivityChanged 정적 이벤트를 사용해 네트워크 연결 변경시 처리하기 (0) | 2022.07.05 |
[C#/MAUI/.NET6] IImage 인터페이스 : Save 메소드를 사용해 이미지 저장하기 (0) | 2022.07.04 |
[C#/MAUI/.NET6] ICanvas 인터페이스 : FillCircle 메소드를 사용해 원 칠하기 (0) | 2022.07.03 |
[C#/MAUI/.NET6] DataTemplate 클래스 : CarouselView 클래스의 ItemTemplate 속성 설정하기 (0) | 2022.07.02 |
[C#/MAUI/.NET6] CarouselView 클래스 : ItemTemplate 속성 사용하기 (0) | 2022.07.01 |
[C#/MAUI/.NET6] IMediaPicker 인터페이스 : PickPhotoAsync 메소드를 사용해 갤러리 사진 구하기 (ANDROID) (0) | 2022.07.01 |
[C#/MAUI/.NET6] ProgressBar 클래스 : ProgressTo 메소드 사용하기 (0) | 2022.07.01 |
[C#/MAUI/.NET6] Button 클래스 : ContentLayout 속성 사용하기 (0) | 2022.06.30 |
댓글을 달아 주세요