Skip to content
draw_arc_aa

draw_arc_aa

Mojo function 🡭

draw_arc_aa

fn def draw_arc_aa(mut canvas: Canvas, cx: Float64, cy: Float64, radius: Float64, start_angle: Float64, end_angle: Float64, color: Color, width: Float64 = 1, supersample: Int = Int(4), dashes: List[Float64] = List(), dash_offset: Float64 = 0, cap: LineCap = LineCap.ROUND, join: LineJoin = LineJoin.ROUND, miter_limit: Float64 = 4)

Anti-aliased version of draw_arc: the arc’s sub-pixel samples (_arc_fpoints) stroked through draw_polyline_aa, so the stroke follows the circle rather than a grid-snapped copy of it, and takes the same dash, cap and join options.

Args:

  • canvas (Canvas): Canvas to draw into.
  • cx (Float64): Center x.
  • cy (Float64): Center y.
  • radius (Float64): Arc radius in pixels.
  • start_angle (Float64): Sweep start, radians, 0 pointing along +x.
  • end_angle (Float64): Sweep end, radians. Below start_angle sweeps the other way round, which reverses the direction a dash pattern and the two caps are laid along.
  • color (Color): Outline 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 along the arc. Empty (default) draws a solid line.
  • dash_offset (Float64): Distance into the dash pattern the arc starts at.
  • cap (LineCap): How the two ends are finished – see LineCap.
  • join (LineJoin): How the corners between samples are turned – see LineJoin. Adjacent samples are nearly collinear, so only a visibly wide stroke shows any difference.
  • miter_limit (Float64): Ratio past which a MITER join falls back to BEVEL, as a multiple of half the stroke width.