Skip to content
fill_ellipse

fill_ellipse

Mojo function 🡭

fill_ellipse

fn def fill_ellipse(mut canvas: Canvas, cx: Int, cy: Int, rx: Int, ry: Int, color: Color)

Fill a solid ellipse: fill_circle generalized to independent x/y radii, one span per row, each pixel set exactly once. The half-width per row shrinks monotonically as |dy| grows, so dx only decreases. The per-row bound is the ellipse equation multiplied through by rx^2 * ry^2 to stay integer-exact instead of taking a sqrt: dx^2*ry^2 + dy^2*rx^2 <= rx^2*ry^2.

Hard-edged; fill_ellipse_aa has a smooth edge.

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.