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="400"
HeightRequest="300"
Drawable="{StaticResource GraphicsDrawableKey}" />
</ContentPage>
728x90
반응형
그리드형(광고전용)
'C# > MAUI' 카테고리의 다른 글
[C#/MAUI/.NET6] Color 클래스 : FromRgba 정적 메소드를 사용해 색상 구하기 (0) | 2022.06.01 |
---|---|
[C#/MAUI/.NET6] Color 클래스 : FromRgb 정적 메소드를 사용해 색상 구하기 (0) | 2022.06.01 |
[C#/MAUI/.NET6] Color 클래스 : FromHsla 정적 메소드를 사용해 색상 구하기 (0) | 2022.06.01 |
[C#/MAUI/.NET6] Color 클래스 : FromHex 정적 메소드를 사용해 색상 구하기 (0) | 2022.06.01 |
[C#/MAUI/.NET6] Color 클래스 : XAML에서 색상 값 사용하기 (0) | 2022.06.01 |
[C#/MAUI/.NET6] FontImageSource 엘리먼트 : IONICONS 폰트 아이콘 표시하기 (0) | 2022.06.01 |
[C#/MAUI/.NET6] Page 클래스 : DisplayPromptAsync 메소드를 사용해 메시지 박스에서 입력받기 (0) | 2022.06.01 |
[C#/MAUI/.NET6] Page 클래스 : DisplayActionSheet 메소드를 사용해 메시지 박스 표시하기 (0) | 2022.06.01 |
[C#/MAUI/.NET6] Page 클래스 : DisplayActionSheet 메소드를 사용해 메시지 박스 표시하기 (0) | 2022.06.01 |
[C#/MAUI/.NET6] Page 클래스 : DisplayAlert 메소드를 사용해 메시지 박스 표시하기 (0) | 2022.06.01 |
댓글을 달아 주세요