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)
{
canvas.FillColor = Colors.Yellow;
canvas.FillRectangle(dirtyRectangle);
canvas.StrokeSize = 10;
canvas.StrokeLineCap = LineCap.Butt;
canvas.StrokeColor = Colors.Red;
canvas.DrawLine(50, 100, 300, 100);
canvas.StrokeSize = 10;
canvas.StrokeLineCap = LineCap.Round;
canvas.StrokeColor = Colors.Red;
canvas.DrawLine(50, 200, 300, 200);
canvas.StrokeSize = 10;
canvas.StrokeLineCap = LineCap.Square;
canvas.StrokeColor = Colors.Red;
canvas.DrawLine(50, 300, 300, 300);
}
#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] IImage 인터페이스 : Downsize 메소드를 사용해 이미지 크기 줄이기 (0) | 2022.06.02 |
---|---|
[C#/MAUI/.NET6] IImage 인터페이스 : Resize 메소드를 사용해 이미지 크기 조정하기 (프리뷰 버전 오류) (0) | 2022.06.02 |
[C#/MAUI/.NET6] ICanvas 인터페이스 : SubtractFromClip 메소드를 사용해 클리핑 설정하기 (0) | 2022.06.02 |
[C#/MAUI/.NET6] ICanvas 인터페이스 : ClipPath 메소드를 사용해 클리핑 설정하기 (0) | 2022.06.02 |
[C#/MAUI/.NET6] ICanvas 인터페이스 : StrokeLineJoin 속성을 사용해 선 연결 스트로크 설정하기 (0) | 2022.06.02 |
[C#/MAUI/.NET6] ICanvas 인터페이스 : SetShadow 메소드를 사용해 그림자 그리기 (0) | 2022.06.02 |
[C#/MAUI/.NET6] ICanvas 인터페이스 : 칠하기 및 윤곽선 그리기 (0) | 2022.06.02 |
[C#/MAUI/.NET6] ICanvas 인터페이스 : DrawString 메소드를 사용해 특성이 있는 문자열 그리기 (0) | 2022.06.02 |
[C#/MAUI/.NET6] 누겟 설치 : Microsoft.Maui.Graphics.Text.Markdig (0) | 2022.06.02 |
[C#/MAUI/.NET6] ICanvas 인터페이스 : DrawString 메소드를 사용해 문자열 그리기 (0) | 2022.06.02 |
댓글을 달아 주세요