PVitt
PVitt

Reputation: 11760

Ellipse with a hole

How can I create a ellipse (path, ...) with a hole in it:

Ellipse with hole

The task is to create a visualization of a three-state-indicator. The different states are visualized by rotating the control several degrees to the left or the right.

Upvotes: 3

Views: 851

Answers (3)

Patrick Klug
Patrick Klug

Reputation: 14391

You can use the CombinedGeometry with the GeometryCombineMode="Exclude"

The documentation has a good example. example of combined geometry

Upvotes: 0

Elad Katz
Elad Katz

Reputation: 7591

=>

    <Path Stroke="Red" StrokeThickness="20">
        <Path.Data>
            <PathGeometry>
                <PathFigure StartPoint="80,0">
                    <ArcSegment x:Name="ArcSeg1" Size="100,100" RotationAngle="0" IsLargeArc="True" 
                SweepDirection="Clockwise" Point="20,0"  >
                    </ArcSegment>
                </PathFigure>
            </PathGeometry>
        </Path.Data>
    </Path>

There are a few relevant properties here, to understand the math behind it see http://www.charlespetzold.com/blog/2008/01/Mathematics-of-ArcSegment.html But basically you're giving the coordinates of the intersection of two ellipses :intersection

StartPoint and Point represents the intersecting points, While Size is the size of the full ellipse. The rest is pretty self explanatory. If you want to rotate it, the easiest and best way would be to use RotateTransform.

Upvotes: 3

Will A
Will A

Reputation: 24988

Would making the 'hole' a white triangle on to of the full circle help? This could be rotated around the center of the circle in conjunction with the 'pointer' (the line).

I can only apologise for my crude rendering

Upvotes: 0

Related Questions