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

40 lines
949 B
Markdown
Raw Normal View History

2016-03-26 00:47:20 +01:00
# Create Image
2016-04-16 00:02:26 +02:00
Create an [Image](/reference/images/image) to show on the [LED screen](/device/screen).
2016-03-26 00:47:20 +01:00
```sig
images.createImage(`
. . # . .
. # # # .
# # # # #
. # # # .
. . # . .
`)
```
### Example: rock, paper, scissors
The following example shows one of three images (rock, paper, or scissors) when you shake the micro:bit:
```
input.onGesture(Gesture.Shake, () => {
let rockpaper = images.createImage(`
. . . . . # # # # # . . . . #
. # # # . # . . . # # # . # .
. # # # . # . . . # . # # . .
. # # # . # . . . # # # . # .
. . . . . # # # # # . . . . #
`)
rockpaper.showFrame(Math.random(3))
})
```
### Lessons
2016-04-13 17:27:45 +02:00
[rock paper scissors](/lessons/rock-paper-scissors), [digital pet](/lessons/digital-pet), [offset-image](/lessons/offset-image)
2016-03-26 00:47:20 +01:00
### See also
2016-04-16 00:02:26 +02:00
[show animation](/reference/basic/show-animation), [image](/reference/images/image), [show image](/reference/image/show-image), [scroll image](/reference/image/scroll-image)
2016-03-26 00:47:20 +01:00