2016-03-26 00:47:20 +01:00
|
|
|
# Clear
|
|
|
|
|
2016-04-02 01:22:47 +02:00
|
|
|
The clear function for images.
|
2016-03-26 00:47:20 +01:00
|
|
|
|
|
|
|
Turn off all the pixels in an [Image](/microbit/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)
|
2016-03-30 06:17:57 +02:00
|
|
|
input.onButtonPressed(Button.A, () => {
|
2016-03-26 00:47:20 +01:00
|
|
|
img.clear()
|
|
|
|
img.showImage(0)
|
|
|
|
})
|
|
|
|
```
|
|
|
|
|
|
|
|
### See also
|
|
|
|
|
|
|
|
[Image](/microbit/reference/image/image), [show animation](/microbit/reference/basic/show-animation), [show image](/microbit/reference/images/show-image), [scroll image](/microbit/reference/images/scroll-image), [create image](/microbit/reference/images/create-image)
|
|
|
|
|