使用Skiasharp创建充满颜色的圆圈

发布于 2025-02-07 05:53:31 字数 118 浏览 1 评论 0原文

我是与Skiasharp一起与Avalonia合作的新手。我查看了如何制作一些基本形状的文档和示例,例如圆圈,矩形等。有人可以就如何制作充满颜色的交叉圆圈提供建议或建议吗?我认为最好进行USERCORTROL,例如WPF。

I am new to working with skiasharp with avalonia. I looked at the documentation and examples of how to make some basic shapes, like circles, rectangles, etc. Can anyone give advice or suggestion on how to make a crossed circle filled with color? I think it would be best to do UserControl, something like in wpf.

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

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

发布评论

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

评论(1

謌踐踏愛綪 2025-02-14 05:53:31

您如何包装(USERCONTROL)真正取决于UI元素的用例和意图。

<Viewbox x:Name="Vol2" 
         Width="25" 
         Height="25">
    <Canvas Width="100" Height="100">
        <Ellipse x:Name="MyCirlce" Width="100" Height="100" Fill="Black">
        </Ellipse>
        <Rectangle Height="50" Fill="White" Width="15" Canvas.Top="50" Canvas.Left="42.5" RenderTransformOrigin="0,0">
            <Rectangle.RenderTransform>
                <RotateTransform Angle="45"></RotateTransform>
            </Rectangle.RenderTransform>
        </Rectangle>
    </Canvas>
</Viewbox>

ViewBox像SVG一样缩放其内容。

然后,我们在其中填充canvas,并添加我们的椭圆。然后,我们添加矩形并在(左,右)中的位置,然后添加rotateTransform

这应该让你前进。

How you package this up (UserControl) really depends on the use case and intention of the UI element.

<Viewbox x:Name="Vol2" 
         Width="25" 
         Height="25">
    <Canvas Width="100" Height="100">
        <Ellipse x:Name="MyCirlce" Width="100" Height="100" Fill="Black">
        </Ellipse>
        <Rectangle Height="50" Fill="White" Width="15" Canvas.Top="50" Canvas.Left="42.5" RenderTransformOrigin="0,0">
            <Rectangle.RenderTransform>
                <RotateTransform Angle="45"></RotateTransform>
            </Rectangle.RenderTransform>
        </Rectangle>
    </Canvas>
</Viewbox>

A ViewBox scales it's content, like an SVG.

We then plop a Canvas in there and add our Ellipse. We then add a Rectangle and position in (Left, Right) and then add a RotateTransform.

This should get you going.

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