Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fill for EllipseGeometry

Tags:

path

geometry

wpf

I need to have some drawing (triangle and circle) as one object (to set it as content). Triangle should be filled and circle shouldn't be filled with color. The problem is that EllipseGeometry doesn't have IsFilled property. If I remove Fill property at Path both wouldn't be filled. How can I have filled PathFigure and not filled Ellipse having them both in one Path parent?

<Path Stroke="#FFF633FF"
      StrokeThickness="1"
      Fill="#FFF633FF">
    <Path.Data>
        <GeometryGroup>
            <EllipseGeometry Center="6,0"
                             RadiusX="4"
                             RadiusY="4">
            </EllipseGeometry>
            <PathGeometry >
                <PathGeometry.Figures>
                    <PathFigure StartPoint="6,-15" 
                                IsClosed="True">
                        <LineSegment Point="1,-25" />
                        <LineSegment Point="11,-25" />
                    </PathFigure>
                </PathGeometry.Figures>
            </PathGeometry>
        </GeometryGroup>
    </Path.Data>
</Path>
like image 789
Dork Avatar asked Dec 03 '25 09:12

Dork


2 Answers

A simple trick would be to replace the EllipseGeometry by a non-filled PathGeometry with two ArcSegments:

<PathGeometry >
    <PathGeometry.Figures>
        <PathFigure StartPoint="2,0" IsFilled="False">
            <ArcSegment Point="10,0" Size="4,4" />
            <ArcSegment Point="2,0" Size="4,4" />
        </PathFigure>
    </PathGeometry.Figures>
</PathGeometry>
like image 53
Clemens Avatar answered Dec 05 '25 02:12

Clemens


The whole point of a geometry is to describe a shape. Stroke and fill are always taken from the owning Path since the Path is responsible for drawing the shape. So what you're asking is not possible. You need to use two Paths here.

like image 43
Joey Avatar answered Dec 05 '25 00:12

Joey



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!