开发者

How to make modifable worm (shape)?

I am making silverlight program where user can add worms to ground. Worms has to modifable.开发者_Go百科 They can have three or more controlpoints where from user can move and edit worm. Worm has to have maximum and minimum length. Also it has to somekind outfit that it looks like worm. I have made pretty good worm with canonical spline but problem is max and minimum lengths and outfit. i am not waiting any ready codes for this but some new ideas how it can be done.

Example made by MSPaint :) http://tinypic.com/r/bgxp3m/7


You can use the Pen tool in Expression Blend to create an open path with bezier curves. Then the Direct Selection tool can modify the points to give you the desired shape. If you do this in a Storyboard, Expression Blend will expand the Path data into uncompressed format, which can be animated, named, and referenced from code behind. Here is a sample worm:

<Grid x:Name="LayoutRoot" Background="White">
    <Grid.Resources>
        <Storyboard x:Name="wriggle">
            <PointAnimation Duration="0:0:0.7" To="59.4217224121094,11.1413049697876" Storyboard.TargetProperty="(Path.Data).(PathGeometry.Figures)[0].(PathFigure.Segments)[1].(BezierSegment.Point1)" Storyboard.TargetName="wormBody" d:IsOptimized="True"/>
            <PointAnimation Duration="0:0:0.7" To="21.5,45.9078826904297" Storyboard.TargetProperty="(Path.Data).(PathGeometry.Figures)[0].(PathFigure.Segments)[0].(BezierSegment.Point2)" Storyboard.TargetName="wormBody" d:IsOptimized="True"/>
            <PointAnimation Duration="0:0:0.7" To="9.25,28.6580047607422" Storyboard.TargetProperty="(Path.Data).(PathGeometry.Figures)[0].(PathFigure.Segments)[0].(BezierSegment.Point1)" Storyboard.TargetName="wormBody" d:IsOptimized="True"/>
        </Storyboard>
    </Grid.Resources>
    <Path x:Name="wormBody" HorizontalAlignment="Left" Height="67.316" Margin="167,150.092,0,0" Stroke="Black" StrokeThickness="10" UseLayoutRounding="False" VerticalAlignment="Top" Width="91">
        <Path.Data>
            <PathGeometry FillRule="EvenOdd">
                <PathFigure IsFilled="True" IsClosed="False" StartPoint="5,62.3157653808594">
                    <BezierSegment Point3="42.2093734741211,24.9581699371338" Point2="4.49375009536743,30.3548755645752" Point1="35.375,53.3601760864258"/>
                    <BezierSegment Point3="86,5" Point2="73.8499984741211,24.9581699371338" Point1="54.1062507629395,22.6553039550781"/>
                </PathFigure>
            </PathGeometry>
        </Path.Data>
    </Path>
    <Ellipse HorizontalAlignment="Left" Height="15" Margin="246,146,0,0" Stroke="Black" StrokeThickness="10" VerticalAlignment="Top" Width="15"/>
</Grid>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜