pxt-calliope/docs/reference/images/create-image.md

55 lines
1.2 KiB
Markdown
Raw Normal View History

2016-03-26 00:47:20 +01:00
# Create Image
2016-11-02 01:44:37 +01:00
Make an [image](/reference/images/image) (picture) for the @boardname@
[LED screen](/device/screen).
2016-03-26 00:47:20 +01:00
```sig
images.createImage(`
. . # . .
. # # # .
# # # # #
. # # # .
. . # . .
`)
```
## Parameters
2016-07-19 00:18:40 +02:00
* ``leds`` is a [string](/types/string) that says which LEDs
2016-07-19 00:18:40 +02:00
on the screen should be on and which should be off.
## Example: Flip-flopping arrow
If you press button `A`, this program will make a picture of an
arrow and show it on the LED screen. If you press button `B`, the
2016-06-18 00:00:24 +02:00
program will show a picture of the arrow upside-down.
```blocks
2020-03-19 16:26:40 +01:00
input.onButtonEvent(Button.A, ButtonEvent.Click, () => {
images.createImage(`
. . # . .
. # # # .
# . # . #
. . # . .
. . # . .
`).showImage(0);
});
2020-03-19 16:26:40 +01:00
input.onButtonEvent(Button.B, ButtonEvent.Click, () => {
images.createImage(`
. . # . .
. . # . .
# . # . #
. # # # .
. . # . .
`).showImage(0);
});
2016-03-26 00:47:20 +01:00
```
## See also
2016-03-26 00:47:20 +01:00
[image](/reference/images/image),
2016-06-18 00:00:24 +02:00
[create big image](/reference/images/create-big-image),
[show image](/reference/images/show-image),
[scroll image](/reference/images/scroll-image), [show animation](/reference/basic/show-animation)
2016-06-18 00:00:24 +02:00