Skip to content
fill_ellipse_aa

fill_ellipse_aa

Mojo function 🡭

fill_ellipse_aa

fn def fill_ellipse_aa(mut canvas: Canvas, cx: Int, cy: Int, rx: Int, ry: Int, color: Color, supersample: Int = Int(4))

Anti-aliased filled ellipse: fill_circle_aa generalized to independent x/y radii, same per-pixel supersampled analytic coverage, each output pixel visited once.

Each sample’s offset is normalized by (rx, ry) before testing against the unit circle: (dx/rx)^2 + (dy/ry)^2 <= 1, which reduces to fill_circle_aa’s dx^2 + dy^2 <= r^2 when rx == ry. The provably-inside/outside fast path works in that normalized space, where a pixel square’s nearest and farthest normalized corners are its raw ones divided by rx/ry.

Args:

  • canvas (Canvas): Canvas to fill into.
  • cx (Int): Center x.
  • cy (Int): Center y.
  • rx (Int): Horizontal radius in pixels.
  • ry (Int): Vertical radius in pixels.
  • color (Color): Fill color.
  • supersample (Int): Sub-pixel grid side length per pixel (N -> N*N samples).
fn def fill_ellipse_aa(mut canvas: Canvas, cx: Float64, cy: Float64, rx: Float64, ry: Float64, color: Color, supersample: Int = Int(4))

fill_ellipse_aa at a sub-pixel center and radii – the same ellipse, 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. draw_ellipse_aa stays whole-pixel, since it draws a fixed ~1px stroke.

Args:

  • canvas (Canvas): Canvas to fill into.
  • cx (Float64): Center x, sub-pixel.
  • cy (Float64): Center y, sub-pixel.
  • rx (Float64): Horizontal radius in pixels, sub-pixel.
  • ry (Float64): Vertical radius in pixels, sub-pixel.
  • color (Color): Fill color.
  • supersample (Int): Sub-pixel grid side length per pixel (N -> N*N samples).