Skip to content
draw_rect

draw_rect

Mojo function 🡭

draw_rect

fn def draw_rect(mut canvas: Canvas, x: Int, y: Int, width: Int, height: Int, color: Color)

Stroke a rectangle’s outline (x, y is the top-left corner).

Draws each edge exactly once: the left/right edges stop short of the corners the top/bottom edges already cover, so a translucent color never blends twice.

Args:

  • canvas (Canvas): Canvas to draw into.
  • x (Int): Rectangle’s left edge.
  • y (Int): Rectangle’s top edge.
  • width (Int): Rectangle’s width.
  • height (Int): Rectangle’s height.
  • color (Color): Outline color.