问题描述
我有三个已知位置,目前我正在开这两行:
I have three known positions, and currently I am driving two lines like so:
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);
结果如下:
所以,你可以看到,这几乎是我想要的,除了我想要更平滑,只是一点点。
So, as you can see, this is almost what I want except that I want it to be more smoothed out, just a little bit.
现在我正在寻找任何方式,我可以设置三个点,将一些平滑/弯曲的水平设置到中间点,然后在其上画一条具有纯色的线。很像我可以在Photoshop中做到这一点:
Now I'm looking for any way I could set three points, set some smooth/curvy level to the middle point and then draw a line with a solid color on it. Much like how I can do this in Photoshop:
或至少得到类似的平滑度。
Or at least get a similar kind of smoothness.
推荐答案
我想你正在寻找splines
I think you are looking for splines
Gabe是正确的即来自窗体
Gabe is correct that is from Forms
在WPF下,你可以尝试一个PolyBezierSegment,但它需要4点。
Under WPF you could try a PolyBezierSegment but it require 4 points. Possible you could put in three points and 1 more to shape it.
<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>
这将产生以下曲线
这篇关于如何在WPF中绘制平滑的曲线?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!