API Reference › Screen — drawing › Screen.clear
method

Screen.clear

Screen.clear(color)

Paints every pixel of the framebuffer a single color, wiping whatever the previous frame drew. Call it first inside your Render handler so each frame starts from a known background instead of leftover pixels. The one argument is a color, which can be a named palette value such as Color.MidnightBlue or a raw hex literal like 0x0d1020. After clearing, draw the scene on top and finish with Screen.show().

Parameters

colorthe background color to fill with, e.g. a Color.* name or a 0xRRGGBB literal

Example

program ClearBackground {
  var elapsed_frames: int = 0

  handler CountFrames phase Update {
    elapsed_frames = elapsed_frames + 1
  }

  handler DrawWorld phase Render {
    Screen.clear(Color.MidnightBlue)
    Screen.draw_number(x: 8, y: 8, value: elapsed_frames, color: Color.White, scale: 1)
    Screen.show()
  }
}
← All symbols