Skip to content

clear_window

malibx.clear_window(mlx: Mlx, win: Window) -> None

MiniLibX: mlx_clear_window

Fills the whole window with black.

Parameters

Name Type Description
mlx Mlx The connection from init
win Window The window to clear

Returns

None.

Raises

Exception When
RuntimeError The window was closed: window is closed

Notes

  • Windows keep their pixels between frames. If things move, clear at the start of each frame in your loop hook, then redraw.
  • If you draw a background image that covers the whole window every frame, you don't need to clear.
  • Black is the only option. For another background color, put a full-window image filled with that color.

Example

def frame(st):
    malibx.clear_window(mlx, win)
    malibx.put_image_to_window(mlx, win, player, st["x"], st["y"])

See also

pixel_put ยท put_image_to_window