0

我正在创建一个自定义形状,确切地说是一个六边形。我将它们绘制在一个中心点周围,如下所示:

PathSegmentCollection segmentCollection = new PathSegmentCollection();
segmentCollection.Add(new LineSegment() { Point = new Point(x + tileXDelta / 2, y + tileRadius / 2) });     // 1
segmentCollection.Add(new LineSegment() { Point = new Point(x + tileXDelta / 2, y-tileRadius / 2) });       // 2
segmentCollection.Add(new LineSegment() { Point = new Point(x + 0, y-tileRadius) });                        // 3
segmentCollection.Add(new LineSegment() { Point = new Point(x-tileXDelta / 2, y-tileRadius / 2) });         // 4
segmentCollection.Add(new LineSegment() { Point = new Point(x - tileXDelta / 2, y + tileRadius / 2) });     // 5
segmentCollection.Add(new LineSegment() { Point = new Point(x + 0, y + tileRadius) });                      // 6
segmentCollection.Add(new LineSegment() { Point = new Point(x + tileXDelta / 2, y + tileRadius / 2) });     // 7

结果是:

在此处输入图像描述

这里的问题是它从中心位置到第一个角画了一条线。有没有办法可以跳过那条线?

4

1 回答 1

1

尽管您的代码段没有显示它,但您应该将此 PathSegmentCollection 放置在具有 StartPoint 属性的 PathFigure 中。您可能需要将其设置为

new Point(x + tileXDelta / 2, y + tileRadius / 2)

此外,一旦定义了 StartPoint,您只需要 PathSegmentCollection 中的最后六个点,因为 StartPoint 将扮演第一个点的角色。

于 2013-05-06T19:50:52.837 回答