2013-05-06 93 views
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 

,其結果是:

enter image description here

的這裏的問題是,它吸引了來自其centerposition到第一個彎道線。有沒有辦法可以跳過那條線?

+0

您的收集點可能不會導致問題。你已經在周邊正確導航。問題很可能在您的代碼中的其他地方。如果問題出在您的細分收藏中,我們會在細分收藏中看到「0,0」,但我們不會。我的猜測是,無論使用這些段進行繪製,都是從不在您的段列表中的點開始,即點0,0。 – ChrisCM 2013-05-06 19:38:04

回答

1

雖然你的代碼片段沒有顯示它,但你應該將此PathSegmentCollection放置在具有StartPoint屬性的PathFigure中。您可能需要這也設置爲

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

,一旦你定義:起點,你只需要最後六分在PathSegmentCollection,如:起點發生在第一點的作用。