pxt-calliope/docs/reference/game/clear.md
2016-04-13 08:27:45 -07:00

40 lines
728 B
Markdown

# Clear
The clear function for images.
Turn off all the pixels in an [Image](/reference/image/image).
### KindScript
```
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](/reference/image/image), [show animation](/reference/basic/show-animation), [show image](/reference/images/show-image), [scroll image](/reference/images/scroll-image), [create image](/reference/images/create-image)