[英]How to draw a smooth curved line in WPF?
我有三個已知位置,目前我正在駕駛兩條線路:
Line line = new Line
{
StrokeThickness = 3,
Stroke = lineColor,
X1 = MyX,
Y1 = MyY,
X2 = MyX,
Y2 = MiddleY
};
Graph.Children.Add(line);
line = new Line
{
StrokeThickness = 3,
Stroke = lineColor,
X1 = MyX,
Y1 = MiddleY,
X2 = TargetX,
Y2 = TargetY
};
Graph.Children.Add(line);
這是結果:
所以,正如你所看到的,這幾乎是我想要的,除了我希望它更平滑,只是一點點。
現在我正在尋找任何可以設置三個點的方法,將一些平滑/彎曲的水平設置到中間點,然后在其上繪制一條帶有純色的線。 就像我在Photoshop中如何做到這一點:
或者至少得到類似的平滑度。
我想你正在尋找樣條
http://msdn.microsoft.com/en-us/library/554h284b.aspx
Gabe是正確的,來自Forms
在WPF下你可以嘗試PolyBezierSegment但它需要4分。 可能你可以分三個點和另外一個來塑造它。
<Canvas>
<Path Stroke="Black" StrokeThickness="10">
<Path.Data>
<PathGeometry>
<PathGeometry.Figures>
<PathFigureCollection>
<PathFigure StartPoint="100,80">
<PathFigure.Segments>
<PathSegmentCollection>
<PolyBezierSegment Points="90,200 140,200 160,200 180,200 430,190 430,280" />
</PathSegmentCollection>
</PathFigure.Segments>
</PathFigure>
</PathFigureCollection>
</PathGeometry.Figures>
</PathGeometry>
</Path.Data>
</Path>
</Canvas>
這導致以下曲線
您想要使用PathFigure ,特別是使用一組BezierSegments 。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.