Skip to content
draw_polyline

draw_polyline

Mojo function 🡭

draw_polyline

fn def draw_polyline(mut canvas: Canvas, points: List[Point], color: Color, dashes: List[Float64] = List(), dash_offset: Float64 = 0)

Connect consecutive points with line segments (Bresenham).

Not closed; draw_polygon closes. Each interior joint is drawn by exactly one segment (the next skips its shared start point), so a translucent color is not blended twice where segments meet. Dash phase carries across joints rather than resetting at a corner.

Args:

  • canvas (Canvas): Canvas to draw into.
  • points (List[Point]): Vertices to connect, in order.
  • color (Color): Line color.
  • dashes (List[Float64]): On/off segment lengths in pixels, cycled along the whole polyline. Empty (default) draws a solid line.
  • dash_offset (Float64): Distance into the dash pattern the polyline starts at.