WPF: get individual waypoints?

I have one Pathin WPF, and I would like to get individual points of this path. Is it possible? (I used the built-in PathSegment WPF, and I would like to get the points that WPF calculated)

Thanks for any hint!

+3
source share
2 answers

Geometry.GetFlattenedPathGeometryreturns a "polygonal approximation of a geometry object". Then you can iterate over shapes and segments of flattened geometry: each shape must consist of one PolyLineSegment, from which you can iterate over the Points property to get points along the path. In this way:

  PathGeometry g = Path.Data.GetFlattenedPathGeometry();

  foreach (var f in g.Figures)
    foreach (var s in f.Segments)
      if (s is PolyLineSegment)
        foreach (var pt in ((PolyLineSegment)s).Points)
          Debug.WriteLine(pt);
+10
source

WPF4 GetPointAtFractionLength, 0.0 1.0.

"" .

+2

Source: https://habr.com/ru/post/1741193/


All Articles