使用 PathGeometry 创建图形实例

    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition/>
            <RowDefinition/>
            <RowDefinition/>
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition/>
            <ColumnDefinition/>
        </Grid.ColumnDefinitions>
        <Path Grid.Row="0" Grid.Column="0" Stroke="#2456ED" StrokeThickness="4">
            <Path.Data>
                <PathGeometry>
                    <PathGeometry.Figures>
                        <PathFigureCollection>
                            <PathFigure StartPoint="10,90">
                                <PathFigure.Segments>
                                    <PathSegmentCollection>
                                        <QuadraticBezierSegment Point1="200,200" Point2="300,100"/>
                                    </PathSegmentCollection>
                                </PathFigure.Segments>
                            </PathFigure>
                        </PathFigureCollection>
                    </PathGeometry.Figures>
                </PathGeometry>
            </Path.Data>
        </Path>
        <Path Grid.Row="1" Grid.Column="0" Stroke="Black" StrokeThickness="3" Data ="F0 M0,100 L180,100 180,10Z"/>

        <Path Grid.Row="2" Grid.Column="0" Stroke="Black" StrokeThickness="1"  Data="M 10,10 A 100,50 45 1 0 200,100" />
        <Path Grid.Row="0" Grid.Column="1"  Fill="LemonChiffon" Stroke="Black" StrokeThickness="1">
            <Path.Data>
                <RectangleGeometry Rect="10,10,105,105" />
            </Path.Data>
        </Path>
        <Path Grid.Row="1" Grid.Column="1" Stroke="Black" StrokeThickness="1" Fill="#CCCCFF">
            <Path.Data>
                <GeometryGroup FillRule="EvenOdd">
                    <LineGeometry StartPoint="10,10" EndPoint="50,30" />
                    <EllipseGeometry Center="40,70" RadiusX="30" RadiusY="30" />
                    <RectangleGeometry Rect="30,55 100 30" />
                </GeometryGroup>
            </Path.Data>
        </Path>
        <Path Grid.Row="2" Grid.Column="1" Stroke="Black" StrokeThickness="1" Data="M 10,100 L 100,100 100,50 Z M 10,10 100,10 100,40 Z" />
    </Grid>

  

image

 

圆化 RectangleGeometry 的角(创建带圆角的矩形)

posted @ 2026-04-01 16:26  echo-efun  阅读(2)  评论(0)    收藏  举报