Skip to content
draw_circle_aa

draw_circle_aa

Mojo function 🡭

draw_circle_aa

fn def draw_circle_aa(mut canvas: Canvas, cx: Int, cy: Int, radius: Int, color: Color, supersample: Int = Int(4), width: Float64 = 1)

Anti-aliased circle outline, width pixels wide (default 1).

fill_circle_aa’s supersampled coverage technique, including the pixel-centered-at-(px,py) convention, testing each sub-sample against a ring (radius +/- width/2) rather than the filled disk.

Args:

  • canvas (Canvas): Canvas to draw into.
  • cx (Int): Center x.
  • cy (Int): Center y.
  • radius (Int): Circle radius in pixels, to the middle of the stroke.
  • color (Color): Outline color.
  • supersample (Int): Sub-pixel grid side length per pixel (N -> N*N samples).
  • width (Float64): Stroke width in pixels.
fn def draw_circle_aa(mut canvas: Canvas, cx: Float64, cy: Float64, radius: Float64, color: Color, supersample: Int = Int(4), width: Float64 = 1)

draw_circle_aa at a sub-pixel center and radius – the same ring, placed and sized 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. A stroke wider than the diameter leaves no hole and draws a disk. A ring never contains a whole pixel square unless it is wide, so the only fast path is the “provably outside” AABB nearest/farthest-point test fill_circle_aa uses.

Args:

  • canvas (Canvas): Canvas to draw into.
  • cx (Float64): Center x, sub-pixel.
  • cy (Float64): Center y, sub-pixel.
  • radius (Float64): Circle radius in pixels, to the middle of the stroke.
  • color (Color): Outline color.
  • supersample (Int): Sub-pixel grid side length per pixel (N -> N*N samples).
  • width (Float64): Stroke width in pixels.