带孔的椭圆

发布于 2024-11-08 20:19:21 字数 141 浏览 0 评论 0原文

如何创建一个有孔的椭圆(路径,...):

带孔的椭圆

任务是创建三状态指示器的可视化。通过将控件向左或向右旋转几度来可视化不同的状态。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

月寒剑心 2024-11-15 20:19:21

=>

    <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>

这里有一些相关的属性,要了解其背后的数学原理,请参阅
http://www.charlespetzold.com/blog/2008/ 01/Mathematics-of-ArcSegment.html
但基本上你给出了两个椭圆相交的坐标:intersection

StartPoint 和 Point 代表相交点,而 Size是完整椭圆的大小。其余的就很不言自明了。
如果你想旋转它,最简单、最好的方法是使用 RotateTransform。

=>

    <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.

江湖彼岸 2024-11-15 20:19:21

将“孔”制作为整圆上的白色三角形会有帮助吗?它可以与“指针”(线)一起围绕圆心旋转。

我只能为我的粗略渲染道歉

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

千仐 2024-11-15 20:19:21

您可以将 CombinedGeometry 与 <代码>GeometryCombineMode="排除"

文档有一个很好的例子。
组合几何示例

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

The documentation has a good example.
example of combined geometry

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文