【声明】优快云只做转发不做时时更新,最新博客请关注博客园 C# 曲线上的点(一) 获取指定横坐标对应的纵坐标值 - 唐宋元明清2188 - 博客园
获取直线上的点,很容易,那曲线呢?二阶贝塞尔、三阶贝塞尔、多段混合曲线,如何获取指定横坐标对应的纵坐标?
如下图形:
实现方案
曲线上的点集
Geometry提供了一个函数GetFlattenedPathGeometry,可以获取其绘制后显示的多边形。
我们可以通过其Figures -> PathSegment -> Point,
1 public List<Point> GetPointsOnPath(Geometry geometry) 2 { 3 List<Point> points = new List<Point>(); 4 PathGeometry pathGeometry = geometry.GetFlattenedPathGeometry(); 5 foreach (var figure in pathGeometry.Figures) 6 { 7