c# - 在C#上以环的形式构造一个形状

标签 c# .net shapes

我需要构造环(从中切出一个半径较小的圆)并将其作为 System.Windows.Shapes.Shape 返回的方法。我可以用 Path 做到这一点吗?可能以其他方式存在?

最佳答案

您可以使用笔触很粗但填充透明的椭圆吗?不可否认,如果您希望环本身的边缘与填充部分的颜色不同......

或者,我会开始查看一个 Path,它包含 GeometryGroup 中的两个 EllipseGeometry 元素和一个 FillRule EvenOddCombineGeometryGeometryCombineModeExclude。例如:

<Path Stroke="Black" StrokeThickness="1" Fill="#CCCCFF">
  <Path.Data>
    <CombinedGeometry GeometryCombineMode="Exclude">
      <CombinedGeometry.Geometry1>
        <EllipseGeometry RadiusX="100" RadiusY="100" Center="125,125" />
      </CombinedGeometry.Geometry1>
      <CombinedGeometry.Geometry2>
        <EllipseGeometry RadiusX="50" RadiusY="50" Center="125,125" />
      </CombinedGeometry.Geometry2>
    </CombinedGeometry>
  </Path.Data>
</Path>

产生这个:

alt text

我说的对吗?

关于c# - 在C#上以环的形式构造一个形状,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4174553/

相关文章:

algorithm - 检查一个矩形是否平分另一个矩形

qt - 如何在 ShapePath 中使用 LinearGradient?

c# - 命名空间 'Amazon' 中不存在“ElasticTranscoder”(您是否缺少程序集引用?)

c# - 使用 C# 的另一个进程的内存使用情况和执行时间?

c# - .NET XmlSerializer 和 C# 中的嵌套类

c# - 时间跨度错误..?

c# - ASP.NET - 指定的网络密码不正确

.net - 构建失败。错误: 'path' cannot be an empty string ("") or start with the null character

vba - 打开 HTML 文档时 Word Shapes 损坏

c# - HttpCacheability.NoCache 和 HttpCacheability.ServerAndNoCache 之间有什么区别?