pxt-calliope/docs/reference/game/clear.md
2020-02-20 04:01:37 +01:00

770 B

Clear

The clear function for images.

Turn off all the pixels in an Image.

JavaScript

export function clear(img: micro_bit.Image)

Parameters

  • none

Example

The following example turns off the pixels of img when the A input button is pressed:

let img = images.createImage(`
. . . . .
. # # # .
. # # # .
. # # # .
. . . . .
`)
img.showImage(0)
input.input.onButtonEvent(Button.A, DAL.MICROBIT_BUTTON_EVT_CLICK, () => {
    img.clear()
    img.showImage(0)
})

See also

Image, show animation, show image, scroll image, create image