gpt4 book ai didi

wpf - 如何在 XAML 中绘制单独的圆圈?

转载 作者:行者123 更新时间:2023-12-01 06:59:13 27 4
gpt4 key购买 nike

我怎样才能画一个这样的圆圈,2 种颜色的 2 部分。我正在用 xaml 编码

enter image description here

<Ellipse Fill="White" HorizontalAlignment="Center" VerticalAlignment="Center" Width="300" Height="300">

</Ellipse>

<Path VerticalAlignment="Top" Fill="Brown" HorizontalAlignment="Left">
<Path.Data>
<PathGeometry>
<PathFigure StartPoint="59,150">
<ArcSegment SweepDirection="Clockwise" Size="141,80" Point="341,150"/>
</PathFigure>
</PathGeometry>
</Path.Data>
</Path>

我试了一下,上面的Path不完整a part 1.帮我试试画吧!

最佳答案

给你:

<Canvas>
<Ellipse Canvas.Left="50" Canvas.Top="50" Width="300" Height="300" Stroke="Black" StrokeThickness="1" Fill="Red" />
<Ellipse Canvas.Left="50" Canvas.Top="50" Width="300" Height="300" Stroke="Black" StrokeThickness="1" Fill="Yellow">
<Ellipse.Clip>
<RectangleGeometry Rect="0 100 300 300" />
</Ellipse.Clip>
</Ellipse>
<Rectangle Canvas.Left="50" Canvas.Top="150" Width="300" Height="200" Stroke="Black" StrokeThickness="1" Fill="Transparent">
<Rectangle.Clip>
<EllipseGeometry Center="150, 50" RadiusX="150" RadiusY="150" />
</Rectangle.Clip>
</Rectangle>
</Canvas>

第一个 Canvas 元素绘制一个红色圆圈,第二个元素在顶部绘制一个黄色圆圈并将其剪辑,第三个元素绘制穿过中间的黑线。结果如下:

enter image description here

编辑:实际上再考虑一下这两个椭圆可以用一个椭圆和一个线性渐变画笔来完成:
<Ellipse Canvas.Left="50" Canvas.Top="50" Width="300" Height="300" Stroke="Black" StrokeThickness="1">
<Ellipse.Fill>
<LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
<GradientStop Color="Red" Offset="0.3333" />
<GradientStop Color="Yellow" Offset="0.3333" />
</LinearGradientBrush>
</Ellipse.Fill>
</Ellipse>

关于wpf - 如何在 XAML 中绘制单独的圆圈?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21621305/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com