开发者

How to fill an overlapped area when FillRule fails?

I'm trying to draw a hand-made DB drum alike shape. The problem is that the top ellipse is not completely filled. Sample:

<Page
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
  <Grid>  
        <Image Width="126" Height="42" Margin="3" HorizontalAlignment="Left" VerticalAlignment="Top">
            <Image.Source>
                <DrawingImage>
                    <DrawingImage.Drawing>
                        <GeometryDrawing Brush="Silver">
                            <GeometryDrawing.Pen>
                                <Pen Brush="Black" Thickness="1" LineJoin="Bevel" EndLineCap="Round" StartLineCap="Round" />
                            </GeometryDrawing.Pen>
                            <GeometryDrawing.Geometry>
                                <GeometryGroup FillRule="NonZero">
                                    <EllipseGeometry Center="62,8" RadiusX="62" RadiusY="5" />
                                    <PathGeometry>
                                        <Path开发者_开发百科Figure StartPoint="0,8" IsClosed="False">
                                            <LineSegment Point="0,38" />
                                            <QuadraticBezierSegment Point1="60,49" Point2="124,38" />
                                            <LineSegment Point="124,8" />
                                        </PathFigure>
                                    </PathGeometry>
                                </GeometryGroup>
                            </GeometryDrawing.Geometry>
                        </GeometryDrawing>
                    </DrawingImage.Drawing>
                </DrawingImage>
            </Image.Source>
        </Image>

  </Grid>
</Page>

Any alternatives to solve this issue? Thanks.


Finally... the solution was to make two separate path figures using arc segments:

<Page  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
       xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Grid>
    <Image Width="126" Height="42" Margin="3" HorizontalAlignment="Left" VerticalAlignment="Top">
        <Image.Source>
            <DrawingImage>
                <DrawingImage.Drawing>
                    <GeometryDrawing Brush="Silver">
                        <GeometryDrawing.Pen>
                            <Pen Brush="Black" Thickness="1" LineJoin="Bevel" EndLineCap="Round" StartLineCap="Round" />
                        </GeometryDrawing.Pen>
                        <GeometryDrawing.Geometry>
                            <GeometryGroup x:Key="Drum" FillRule="NonZero">
                                <PathGeometry>
                                    <PathFigure StartPoint="0,6" IsClosed="True">
                                        <ArcSegment Point="125,6" IsLargeArc="False" IsStroked="True" SweepDirection="Clockwise" Size="15,1.5" />
                                        <ArcSegment Point="0,6" IsLargeArc="False" IsStroked="True" SweepDirection="Clockwise" Size="15,1.5" />
                                    </PathFigure>
                                </PathGeometry>
                                <PathGeometry>
                                    <PathFigure StartPoint="0,6" IsClosed="True">
                                        <ArcSegment Point="125,6" IsLargeArc="False" IsStroked="True" Size="15,1.5" IsSmoothJoin="True" />
                                        <LineSegment Point="125,35" IsSmoothJoin="True" />
                                        <ArcSegment Point="0,35" IsLargeArc="False" IsStroked="True" SweepDirection="Clockwise" Size="15,1.5" IsSmoothJoin="True" />
                                        <LineSegment Point="0,6" IsSmoothJoin="True" />
                                    </PathFigure>
                                </PathGeometry>
                            </GeometryGroup>
                        </GeometryDrawing.Geometry>
                    </GeometryDrawing>
                </DrawingImage.Drawing>
            </DrawingImage>
        </Image.Source>
    </Image>  
</Grid>
</Page>
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜