我想在一条线周围添加边框。我正试图沿着现有的一条线(或任何其他方法)画两条线。去实现它。我试着画两条粗细不同的线。但我想要一个灵活的方法。
我也试过用DrawingBrush,但是旋转和缩放是个问题。
简单的代码如下所示。但我想知道是否有其他方便的方法为路径线添加边框。此外,此方法中线的起点和终点未被“边框”包围。
<Path
StrokeThickness="3"
StrokeDashCap="Round"
Stroke="Black"
Data="{Binding PathGeometry}"
>
</Path>
<Path
StrokeThickness="8"
StrokeDashCap="Round"
Stroke="{Binding Brush}"
Data="{Binding PathGeometry}"
>
</Path>
最佳答案
Vector vLine = ( p1 - p0 ).Normalized();
Vector vPerp = new Vector( -vLine.Y, vLine.X );
Point newp0 = p0 + vPerp * offset distance
Point newp1 = p1 + vPerp * offset distance
DrawLine( newp0, newp1 );
关于c# - 如何在 WPF 中沿路径绘制平行线,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32109264/