방법: 그리기 클리핑

업데이트: 2007년 11월

이 예제에서는 Drawing에 대해 클립 영역을 정의하는 방법을 보여 줍니다.

Drawing에 대해 클립 영역을 정의하려면 DrawingGroup을 사용하십시오. DrawingGroup 클래스는 고유의 클립 영역을 정의하는 데 사용할 수 있는 유일한 Drawing 개체 형식입니다.

클립 영역을 정의하여 DrawingGroup 개체의 ClipGeometry 속성에 적용하려면 Geometry를 사용하십시오.

예제

다음 그림에서는 타원형 클립을 적용하기 전과 후의 DrawingGroup을 보여 줍니다.

정의된 클립 영역이 있는 DrawingGroup

다음 예제에서는 DrawingGroup을 사용하여 여러 개의 GeometryDrawing 개체에 ClipGeometry를 적용합니다.

<Page 
  xmlns="https://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="https://schemas.microsoft.com/winfx/2006/xaml"
  xmlns:PresentationOptions="https://schemas.microsoft.com/winfx/2006/xaml/presentation/options" 
  xmlns:mc="https://schemas.openxmlformats.org/markup-compatibility/2006"
  mc:Ignorable="PresentationOptions"
  Background="White" Margin="20">

  <Border BorderBrush="Gray" BorderThickness="1" 
    HorizontalAlignment="Left" VerticalAlignment="Top"
    Margin="20">
    <Image Stretch="None" HorizontalAlignment="Left">
      <Image.Source>
        <DrawingImage PresentationOptions:Freeze="True">
          <DrawingImage.Drawing>

            <!-- A DrawingGeometry with an elliptical clip region. -->
            <DrawingGroup>
              <GeometryDrawing Brush="Pink">
                <GeometryDrawing.Geometry>
                  <RectangleGeometry Rect="0,0,50,85" />
                </GeometryDrawing.Geometry>
              </GeometryDrawing>
              <GeometryDrawing Brush="Lime" 
                Geometry="M 25,25 L 0,50 25,75 50,50 25,25 25,0">
                <GeometryDrawing.Pen>
                  <Pen Thickness="10" Brush="Black" />
                </GeometryDrawing.Pen>
              </GeometryDrawing>
              <GeometryDrawing Brush="Lime">
                <GeometryDrawing.Geometry>
                  <EllipseGeometry Center="10,10" RadiusX="5" RadiusY="5" />
                </GeometryDrawing.Geometry>
                <GeometryDrawing.Pen>
                  <Pen Thickness="2" Brush="Black" />
                </GeometryDrawing.Pen>
              </GeometryDrawing>

              <DrawingGroup.ClipGeometry>
                <EllipseGeometry Center="25,50" RadiusX="25" RadiusY="50" />
              </DrawingGroup.ClipGeometry>
            </DrawingGroup>
          </DrawingImage.Drawing>
        </DrawingImage>
      </Image.Source>
    </Image>
  </Border>


</Page>

참고 항목

개념

Drawing 개체 개요

Geometry 개요

참조

Geometry

Freeze

PresentationOptions:Freeze 특성