pxt-calliope/docs/reference/game/clear.md
Sam El-Husseini e3975e65e5 pxt-microbit Accessibility PR (#529)
* Accessibility changes
2017-09-07 13:42:08 -07:00

735 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.onButtonPressed(Button.A, () => {
    img.clear()
    img.showImage(0)
})

See also

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