1.8 KiB
1.8 KiB
Show Image
The show image function. #showimage #docs #image #screen #LED
Show an Image on the LED screen, followed by a 400ms pause.
Block Editor
KindScript
export function showImage(_this: micro_bit.Image, xOffset: number)
Parameters
- x offset - Number; the horizontal starting point of an image; use 0 for the first frame of the image, 5 for the second frame of the image, 10 for the third frame and so on.
Create image and show image
Use the image editor to create images using the create image function, and then use show image
like this:
let img = images.createImage(`
. . # . .
. # . # .
. . # . .
. # . # .
. . # . .
`)
img.showImage(0)
Example: display numbers 1-5
The following example creates an image with 5 frames and then uses a for loop to show each frame on the screen:
let img2 = images.createImage(`
. . # . . . # # # # . # # # . . . . # . . # # # .
. # # . . . . . . # . . . # . . . # # . . # . . .
. . # . . . . . # . . . # . . . # # # # . # # # .
. . # . . . . # . . . . . # . . . . # . . . . # .
. . # . . . # # # # . # # # . . . . # . . # # # .
`)
for (let i = 0; i < 5; i++) {
img2.showImage(i * 5)
basic.pause(1000)
}
Lessons
rock paper scissors, digital pet, offset-image