첨부 실행 코드는 나눔고딕코딩 폰트를 사용합니다.
728x90
반응형
728x170

■ CombinedGeometry 엘리먼트의 GeometryCombineMode 속성을 사용하는 방법을 보여준다.

TestProject.zip
0.01MB

▶ 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
반응형
그리드형(광고전용)
Posted by icodebroker

댓글을 달아 주세요