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
|
|
|
|
2016-04-16 00:02:26 +02:00
|
|
|
Turn off all the pixels in an [Image](/reference/images/image).
|
2016-03-26 00:47:20 +01:00
|
|
|
|
2019-12-02 05:58:26 +01:00
|
|
|
## JavaScript
|
2016-03-26 00:47:20 +01:00
|
|
|
|
2016-08-09 17:52:24 +02:00
|
|
|
```sig
|
2016-03-26 00:47:20 +01:00
|
|
|
export function clear(img: micro_bit.Image)
|
|
|
|
```
|
|
|
|
|
2019-12-02 05:58:26 +01:00
|
|
|
## Parameters
|
2016-03-26 00:47:20 +01:00
|
|
|
|
|
|
|
* none
|
|
|
|
|
2019-12-02 05:58:26 +01:00
|
|
|
## Example
|
2016-03-26 00:47:20 +01:00
|
|
|
|
|
|
|
The following example turns off the pixels of `img` when the A input button is pressed:
|
|
|
|
|
2016-08-09 17:52:24 +02:00
|
|
|
```blocks
|
2016-03-26 00:47:20 +01:00
|
|
|
let img = images.createImage(`
|
|
|
|
. . . . .
|
|
|
|
. # # # .
|
|
|
|
. # # # .
|
|
|
|
. # # # .
|
|
|
|
. . . . .
|
|
|
|
`)
|
|
|
|
img.showImage(0)
|
2020-02-20 17:00:11 +01:00
|
|
|
input.input.onButtonEvent(Button.A, ButtonEvent.Click, () => {
|
2016-03-26 00:47:20 +01:00
|
|
|
img.clear()
|
|
|
|
img.showImage(0)
|
|
|
|
})
|
|
|
|
```
|
|
|
|
|
2019-12-02 05:58:26 +01:00
|
|
|
## See also
|
2016-03-26 00:47:20 +01:00
|
|
|
|
2016-04-16 00:02:26 +02:00
|
|
|
[Image](/reference/images/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)
|
2016-03-26 00:47:20 +01:00
|
|
|
|