반응형
<Window x:Class="WpfApplication19.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="Bezier Curve" Height="300" Width="300"> <Window.Resources> <SolidColorBrush x:Key="MyGrayGridBrush" Color="YellowGreen"/> </Window.Resources> <Viewbox Stretch="Fill"> <Border Margin="5" BorderBrush="Black" BorderThickness="1" Background="{StaticResource MyGrayGridBrush}" HorizontalAlignment="Left"> <Canvas x:Name="canvas1" Width="300" Height="270"> <Path Stroke="Black" StrokeThickness="5"> <Path.Data> <PathGeometry> <PathFigure StartPoint="20,20"> <BezierSegment x:Name="bezierSegment" Point1="150,50" Point2="60,160" Point3="250,230"/> </PathFigure> </PathGeometry> </Path.Data> </Path> <Path x:Name="path1" Fill="Red" Stroke="Red"> <Path.Data> <GeometryGroup> <LineGeometry x:Name="line1" StartPoint="20,20" EndPoint="150,50"/> <EllipseGeometry x:Name="ellipse1" Center="150,50" RadiusX="5" RadiusY="5" /> <LineGeometry x:Name="line2" StartPoint="60,160" EndPoint="250,230"/> <EllipseGeometry x:Name="ellipse2" Center="60,160" RadiusX="5" RadiusY="5" /> </GeometryGroup> </Path.Data> </Path> <!-- Set animation: --> <Canvas.Triggers> <EventTrigger RoutedEvent="Canvas.Loaded"> <BeginStoryboard> <Storyboard RepeatBehavior="Forever" AutoReverse="True"> <PointAnimation Storyboard.TargetName="bezierSegment" Storyboard.TargetProperty="Point1" From="50 20" To="250 20" Duration="0:0:5"/> <PointAnimation Storyboard.TargetName="line1" Storyboard.TargetProperty="EndPoint" From="50 20" To="250 20" Duration="0:0:5"/> <PointAnimation Storyboard.TargetName="ellipse1" Storyboard.TargetProperty="Center" From="50 20" To="250 20" Duration="0:0:5"/> <PointAnimation Storyboard.TargetName="bezierSegment" Storyboard.TargetProperty="Point2" From="60 50" To="60 250" Duration="0:0:5"/> <PointAnimation Storyboard.TargetName="line2" Storyboard.TargetProperty="StartPoint" From="60 50" To="60 250" Duration="0:0:5"/> <PointAnimation Storyboard.TargetName="ellipse2" Storyboard.TargetProperty="Center" From="60 50" To="60 250" Duration="0:0:5"/> </Storyboard> </BeginStoryboard> </EventTrigger> </Canvas.Triggers> </Canvas> </Border> </Viewbox> </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 PathGeometry Class (0) | 2013.07.11 |
WPF 2D Combined Geometry (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 |