pxt-calliope/docs/reference/images/create-image.md
2016-04-15 15:02:26 -07:00

949 B

Create Image

Create an Image to show on the LED screen.

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

rock paper scissors, digital pet, offset-image

See also

show animation, image, show image, scroll image