Skip to content
draw_polygon_aa

draw_polygon_aa

Mojo function 🡭

draw_polygon_aa

fn def draw_polygon_aa(mut canvas: Canvas, points: List[Point], color: Color, width: Float64 = 1, supersample: Int = Int(4), dashes: List[Float64] = List(), dash_offset: Float64 = 0, join: LineJoin = LineJoin.ROUND, miter_limit: Float64 = 4)

Anti-aliased polygon outline; draw_polygon is the hard-edged version. The closing segment is stroked like any other, so dash phase carries across the closing vertex.

Args:

  • canvas (Canvas): Canvas to draw into.
  • points (List[Point]): Vertices to connect, in order.
  • color (Color): Line color.
  • width (Float64): Stroke width in pixels.
  • supersample (Int): Sub-pixel grid side length per pixel (N -> N*N samples) for the one stroke that still samples: a closed one whose inner ring inverts, the width being past the curve’s radius of curvature. Every other stroke rasterizes by exact area and ignores it. See _stroke_edges.
  • dashes (List[Float64]): On/off segment lengths in pixels, cycled all the way around the polygon. Empty (default) draws a solid line.
  • dash_offset (Float64): Distance into the dash pattern the polygon starts at.
  • join (LineJoin): How corners are turned – see LineJoin.
  • miter_limit (Float64): Ratio past which a MITER join falls back to BEVEL, as a multiple of half the stroke width.
fn def draw_polygon_aa(mut canvas: Canvas, points: List[FPoint], color: Color, width: Float64 = 1, supersample: Int = Int(4), dashes: List[Float64] = List(), dash_offset: Float64 = 0, join: LineJoin = LineJoin.ROUND, miter_limit: Float64 = 4)

draw_polygon_aa at sub-pixel vertices – the same polygon outline, placed to a fraction of a pixel rather than snapped to the pixel grid.

This is the real implementation; the whole-pixel overload above converts and calls it.

Args:

  • canvas (Canvas): Canvas to draw into.
  • points (List[FPoint]): Vertices to connect, in order, at sub-pixel positions.
  • color (Color): Line color.
  • width (Float64): Stroke width in pixels.
  • supersample (Int): Sub-pixel grid side length per pixel (N -> N*N samples) for the one stroke that still samples: a closed one whose inner ring inverts, the width being past the curve’s radius of curvature. Every other stroke rasterizes by exact area and ignores it. See _stroke_edges.
  • dashes (List[Float64]): On/off segment lengths in pixels. Empty (default) draws a solid line.
  • dash_offset (Float64): Distance into the dash pattern to start at.
  • join (LineJoin): How corners are turned – see LineJoin.
  • miter_limit (Float64): Ratio past which a MITER join falls back to BEVEL, as a multiple of half the stroke width.