fill_rect
Mojo function 🡭
fill_rect
fn def fill_rect(mut canvas: Canvas, x: Int, y: Int, width: Int, height: Int, color: Color)Fill a solid rectangle (x, y is the top-left corner).
Args:
- canvas (
Canvas): Canvas to fill 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): Fill color.
fn def fill_rect(mut canvas: Canvas, x: Float64, y: Float64, width: Float64, height: Float64, color: Color)fill_rect for a geometric rectangle: the box from (x, y) spanning width x height, in the pixel-center convention (pixel k spans k - 0.5 to k + 0.5), snapped to whole pixels. Each edge goes to the nearest pixel boundary, so fill_rect(19.5, 4.5, 40.0, 30.0) is fill_rect(20, 5, 40, 30) exactly and an edge at 20.4 starts at pixel 21. Hard-edged; for an anti-aliased rectangle fill a Path.rect with fill_path_aa.
Under a transform the box is mapped first and snapped in device
space, so a supersampling caller (see downsample) gets exact
blocks.
Args:
- canvas (
Canvas): Canvas to fill into. - x (
Float64): Left edge. - y (
Float64): Top edge. - width (
Float64): Width. - height (
Float64): Height. - color (
Color): Fill color.