본문 바로가기

.NET/WPF 2D

WPF 2D Combined Geometry

반응형







<Window x:Class="WpfApplication17.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Combined Geometry" Height="340" Width="300">
<Window.Resources>
<SolidColorBrush x:Key="MyGrayGridBrush" Color="YellowGreen"/>
</Window.Resources>
<Border Margin="5" BorderBrush="Black" BorderThickness="1"  
Background="{StaticResource MyGrayGridBrush}" 
HorizontalAlignment="Left">
<Canvas Width="300" Height="340" Margin="5">
<Grid>
<Grid.ColumnDefinitions>
	<ColumnDefinition Width="140"/>
	<ColumnDefinition Width="140"/>
</Grid.ColumnDefinitions>
<StackPanel Grid.Column="0">
	<TextBlock FontSize="12pt" Text="Union" 
                Margin="40,5,5,10"/>
	<Path Fill ="LightBlue" Stroke="Blue">
		<Path.Data>
			<CombinedGeometry 
                GeometryCombineMode="Union">
				<CombinedGeometry.Geometry1>
					<EllipseGeometry  
                        Center="50,50" 
                        RadiusX="50" 
                        RadiusY="50"/>
				</CombinedGeometry.Geometry1>
				<CombinedGeometry.Geometry2>
					<EllipseGeometry  
                        Center="80,50"  
                        RadiusX="50" 
                        RadiusY="50"/>
				</CombinedGeometry.Geometry2>
			</CombinedGeometry>
		</Path.Data>
	</Path>
 
	<TextBlock FontSize="12pt" Text="Xor" 
                Margin="45,15,5,10"/>
	<Path Fill ="LightBlue" Stroke="Blue">
		<Path.Data>
			<CombinedGeometry  
                GeometryCombineMode="Xor">
				<CombinedGeometry.Geometry1>
					<EllipseGeometry  
                        Center="50,50" 
                        RadiusX="50"  
                        RadiusY="50"/>
				</CombinedGeometry.Geometry1>
				<CombinedGeometry.Geometry2>
					<EllipseGeometry  
                        Center="80,50" 
                        RadiusX="50" 
                        RadiusY="50"/>
				</CombinedGeometry.Geometry2>
			</CombinedGeometry>
		</Path.Data>
	</Path>
</StackPanel>
 
<StackPanel Grid.Column="1">
	<TextBlock FontSize="12pt" 
        Text="Intersect" Margin="30,5,5,10"/>
	<Path Fill ="LightBlue" Stroke="Blue"  
            Margin="5,0,0,0">
		<Path.Data>
			<CombinedGeometry  
                GeometryCombineMode="Intersect">
				<CombinedGeometry.Geometry1>
					<EllipseGeometry 
                        Center="50,50" 
                        RadiusX="50" 
                        RadiusY="50"/>
				</CombinedGeometry.Geometry1>
				<CombinedGeometry.Geometry2>
					<EllipseGeometry  
                        Center="80,50" 
                        RadiusX="50" 
                        RadiusY="50"/>
				</CombinedGeometry.Geometry2>
			</CombinedGeometry>
		</Path.Data>
	</Path>
 
	<TextBlock FontSize="12pt" Text="Exclude" 
                Margin="35,15,5,10"/>
	<Path Fill ="LightBlue" Stroke="Blue" 
            Margin="10,0,0,0">
		<Path.Data>
			<CombinedGeometry 
                GeometryCombineMode="Exclude">
				<CombinedGeometry.Geometry1>
					<EllipseGeometry  
                        Center="50,50" RadiusX="50" 
                        RadiusY="50"/>
				</CombinedGeometry.Geometry1>
				<CombinedGeometry.Geometry2>
					<EllipseGeometry 
                        Center="80,50" 
                        RadiusX="50" 
                        RadiusY="50"/>
				</CombinedGeometry.Geometry2>
			</CombinedGeometry>
		</Path.Data>
	</Path>
</StackPanel>
</Grid>
</Canvas>
</Border>
</Window>


reference : Practical WPF Graphics Programming



'.NET > WPF 2D' 카테고리의 다른 글

WPF Interactive 2D Drawing  (0) 2013.07.11
WPF 2D Geometry and Mini-Language  (0) 2013.07.11
WPF 2D Bezier Curve  (0) 2013.07.11
WPF 2D PathGeometry Class  (0) 2013.07.11
WPF 2D Geometry Group  (0) 2013.07.11
WPF Geometry and 2D Drawing  (0) 2013.07.11
WPF 2D Composite Transforms  (0) 2013.07.04
WPF 2D SkewTransform  (0) 2013.07.04