Draw figure with “NonZero” FillRule

image_pdfimage_print
   
     
<Canvas xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        TextBlock.FontSize="16">
    <Canvas.Resources>
        <Style x:Key="figure">
            <Setter Property="Polygon.Points"
                    Value="0 48, 0 144, 96 150, 100 0, 192 0, 192 96, 50 96, 48 192, 150 200 144 48" />
            <Setter Property="Polygon.Fill"
                    Value="Black" />
            <Setter Property="Polygon.Stroke"
                    Value="Yellow" />
            <Setter Property="Polygon.StrokeThickness"
                    Value="3" />
        </Style>
    </Canvas.Resources>

    <TextBlock Canvas.Left="288" Canvas.Top="24"
               Text="FillRule = NonZero" />

    <Polygon Style="{StaticResource figure}"
             FillRule="NonZero"
             Canvas.Left="288" Canvas.Top="72" />
</Canvas>

   
    
    
    
    
     


Draw second figure with “NonZero” FillRule

image_pdfimage_print


   
     

<Canvas xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        TextBlock.FontSize="16">
    <Canvas.Resources>
        <Style x:Key="star">
            <Setter Property="Polygon.Points"
                    Value="0 -96, 56, 78, -91 -30, 91 -30, -56 78" />
            <Setter Property="Polygon.Fill"
                    Value="Blue" />
            <Setter Property="Polygon.Stroke"
                    Value="Red" />
            <Setter Property="Polygon.StrokeThickness"
                    Value="3" />
        </Style>
    </Canvas.Resources>
    <TextBlock Canvas.Left="288" Canvas.Top="24"
               Text="FillRule = NonZero" />
 
    <Polygon Style="{StaticResource star}"
             FillRule="NonZero"
             Canvas.Left="360" Canvas.Top="168" />
</Canvas>

   
    
    
    
    
     


Star Polygon

image_pdfimage_print


   
     

<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    x:Class="Microsoft.Samples.Graphics.RectangleExample"
    WindowTitle="Example">
  <Canvas>

        <Polygon Name="star" 
          Stroke="Blue" 
          Fill="DarkOrange" 
          StrokeThickness="2.0" 
          Points="176,50 189,15 186,113 200,17 26,240 189,198 176,34 163,198 66,240 151,17 66,113 163,155">
        </Polygon>

  </Canvas>
</Page>

   
    
    
    
    
     


Fill Polygon with RadialGradientBrush

image_pdfimage_print


   
     
<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    x:Class="Microsoft.Samples.Graphics.RectangleExample"
    WindowTitle="Example">
  <Canvas>

        <Polygon Name="hexagon"
          Stroke="Blue"
          StrokeThickness="2.0"
          Points="16,130 302,13 304,249 76,322 493,249 495,103">
          <Polygon.Fill>
            <RadialGradientBrush GradientOrigin="0.5,0.5" Center="0.5,0.5" RadiusX="0.5" RadiusY="0.5">
              <RadialGradientBrush.GradientStops>
                <GradientStop Color="Yellow" Offset="0" />
                <GradientStop Color="Gold" Offset="0.25" />
              </RadialGradientBrush.GradientStops>
            </RadialGradientBrush>
          </Polygon.Fill>
        </Polygon>
   
  </Canvas>
</Page>