728x90
반응형
728x170
■ CombinedGeometry 엘리먼트의 GeometryCombineMode 속성을 사용하는 방법을 보여준다.
▶ MainWindow.xaml
<Window x:Class="TestProject.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:options="http://schemas.microsoft.com/winfx/2006/xaml/presentation/options"
Width="800"
Height="600"
Title="TestProject"
FontFamily="나눔고딕코딩"
FontSize="16">
<Window.Resources>
<DrawingBrush x:Key="GridDrawingBrushKey"
ViewportUnits="Absolute"
Viewport="0 0 10 10"
TileMode="Tile"
options:Freeze="True">
<DrawingBrush.Drawing>
<DrawingGroup>
<DrawingGroup.Children>
<GeometryDrawing Brush="White">
<GeometryDrawing.Geometry>
<RectangleGeometry Rect="0 0 1 1" />
</GeometryDrawing.Geometry>
</GeometryDrawing>
<GeometryDrawing
Brush="#ccccff"
Geometry="M 0 0 L 1 0 1 0.1 0 0.1 Z" />
<GeometryDrawing
Brush="#ccccff"
Geometry="M 0 0 L 0 1 0.1 1 0.1 0 Z" />
</DrawingGroup.Children>
</DrawingGroup>
</DrawingBrush.Drawing>
</DrawingBrush>
</Window.Resources>
<ScrollViewer>
<StackPanel
HorizontalAlignment="Center"
Margin="10">
<TextBlock Margin="0 0 0 5">Source</TextBlock>
<Border
Width="200"
Height="150"
BorderThickness="3"
BorderBrush="Black"
Background="{StaticResource GridDrawingBrushKey}">
<Path
StrokeThickness="3"
Stroke="Black"
Fill="#ccccff">
<Path.Data>
<GeometryGroup FillRule="NonZero">
<EllipseGeometry
Center="75 75"
RadiusX="50"
RadiusY="50" />
<EllipseGeometry
Center="125 75"
RadiusX="50"
RadiusY="50" />
</GeometryGroup>
</Path.Data>
</Path>
</Border>
<TextBlock Margin="0 10 0 5">GeometryCombineMode="Exclude"</TextBlock>
<Border
Width="200"
Height="150"
BorderThickness="3"
BorderBrush="Black"
Background="{StaticResource GridDrawingBrushKey}">
<Path
StrokeThickness="3"
Stroke="Black"
Fill="#ccccff">
<Path.Data>
<CombinedGeometry GeometryCombineMode="Exclude">
<CombinedGeometry.Geometry1>
<EllipseGeometry
Center="75 75"
RadiusX="50"
RadiusY="50" />
</CombinedGeometry.Geometry1>
<CombinedGeometry.Geometry2>
<EllipseGeometry
Center="125 75"
RadiusX="50"
RadiusY="50" />
</CombinedGeometry.Geometry2>
</CombinedGeometry>
</Path.Data>
</Path>
</Border>
<TextBlock Margin="0 10 0 5">GeometryCombineMode="Intersect"</TextBlock>
<Border
Width="200"
Height="150"
BorderThickness="3"
BorderBrush="Black"
Background="{StaticResource GridDrawingBrushKey}">
<Path
StrokeThickness="3"
Stroke="Black"
Fill="#ccccff">
<Path.Data>
<CombinedGeometry GeometryCombineMode="Intersect">
<CombinedGeometry.Geometry1>
<EllipseGeometry
Center="75 75"
RadiusX="50"
RadiusY="50" />
</CombinedGeometry.Geometry1>
<CombinedGeometry.Geometry2>
<EllipseGeometry
Center="125 75"
RadiusX="50"
RadiusY="50" />
</CombinedGeometry.Geometry2>
</CombinedGeometry>
</Path.Data>
</Path>
</Border>
<TextBlock Margin="0 10 0 5">GeometryCombineMode="Union"</TextBlock>
<Border
Width="200"
Height="150"
BorderThickness="3"
BorderBrush="Black"
Background="{StaticResource GridDrawingBrushKey}">
<Path
StrokeThickness="3"
Stroke="Black"
Fill="#ccccff">
<Path.Data>
<CombinedGeometry GeometryCombineMode="Union">
<CombinedGeometry.Geometry1>
<EllipseGeometry
Center="75 75"
RadiusX="50"
RadiusY="50" />
</CombinedGeometry.Geometry1>
<CombinedGeometry.Geometry2>
<EllipseGeometry
Center="125 75"
RadiusX="50"
RadiusY="50" />
</CombinedGeometry.Geometry2>
</CombinedGeometry>
</Path.Data>
</Path>
</Border>
<TextBlock Margin="0 10 0 5">GeometryCombineMode="Xor"</TextBlock>
<Border
Width="200"
Height="150"
BorderThickness="3"
BorderBrush="Black"
Background="{StaticResource GridDrawingBrushKey}">
<Path
Stroke="Black"
StrokeThickness="3"
Fill="#ccccff">
<Path.Data>
<CombinedGeometry GeometryCombineMode="Xor">
<CombinedGeometry.Geometry1>
<EllipseGeometry
Center="75 75"
RadiusX="50"
RadiusY="50" />
</CombinedGeometry.Geometry1>
<CombinedGeometry.Geometry2>
<EllipseGeometry
Center="125 75"
RadiusX="50"
RadiusY="50" />
</CombinedGeometry.Geometry2>
</CombinedGeometry>
</Path.Data>
</Path>
</Border>
</StackPanel>
</ScrollViewer>
</Window>
728x90
반응형
그리드형(광고전용)
'C# > WPF' 카테고리의 다른 글
[C#/WPF] GeometryGroup 엘리먼트 : FillRule 속성을 EvenOdd로 설정해 동심원 만들기 (0) | 2023.04.01 |
---|---|
[C#/WPF] SizeAnimation 클래스 : ArcSegment 객체의 크기를 변경하는 애니메이션 만들기 (0) | 2023.04.01 |
[C#/WPF] PointAnimation 클래스 : 공을 일정 구간에서 반복적으로 움직이기 (0) | 2023.04.01 |
[C#/WPF] PointAnimation 엘리먼트 : 공을 일정 구간에서 반복적으로 움직이기 (0) | 2023.04.01 |
[C#/WPF] Path 엘리먼트 : Data 속성에서 패스 미니 언어 사용하기 (0) | 2023.03.30 |
[C#/WPF] ImageDrawing 엘리먼트 : Rect/ImageSource 속성을 사용해 이미지 드로잉 그리기 (0) | 2023.03.26 |
[C#/WPF] DrawingGroup 엘리먼트 : BitmapEffect/OpacityMask 속성을 사용해 드로잉 그리기 (0) | 2023.03.26 |
[C#/WPF] DrawingGroup 엘리먼트 : 합성 드로잉 그리기 (0) | 2023.03.26 |
[C#/WPF] DrawingGroup 엘리먼트 : GuidelineSet 객체를 설정해 드로잉 만들기 (0) | 2023.03.26 |
[C#/WPF] DrawingGroup 클래스 : GuidelineSet 객체를 설정해 드로잉 만들기 (0) | 2023.03.26 |
댓글을 달아 주세요