#nullable disable namespace Terminal.Gui.Views; /// Sequence of lines to connect points e.g. of a public class PathAnnotation : IAnnotation { /// Color for the line that connects points public Attribute? LineColor { get; set; } /// The symbol that gets drawn along the line, defaults to '.' public Rune LineRune { get; set; } = new ('.'); /// Points that should be connected. Lines will be drawn between points in the order they appear in the list public List Points { get; set; } = new (); /// True to add line before plotting series. Defaults to false public bool BeforeSeries { get; set; } /// Draws lines connecting each of the /// public void Render (GraphView graph) { graph.SetAttribute (LineColor ?? graph.GetAttributeForRole (VisualRole.Normal)); foreach (LineF line in PointsToLines ()) { Point start = graph.GraphSpaceToScreen (line.Start); Point end = graph.GraphSpaceToScreen (line.End); graph.DrawLine (start, end, LineRune); } } /// Generates lines joining /// private IEnumerable PointsToLines () { for (var i = 0; i < Points.Count - 1; i++) { yield return new (Points [i], Points [i + 1]); } } }