Width

The width function.

Get the width of an Image in columns.

images.createImage().width();

Parameters

Returns

The following example gets the width of img and stores it in the w variable:

let img = images.createImage(`
. . # . . . . . . .
. # . # . . . # . .
. . # . . . . . . .
. # . # . . . # . .
. . # . . . . . . .
`)
let w = img.width()

Example: show each frame

The following example uses the width function with a for loop to show each image frame on the screen:

let img2 = images.createImage(`
. . # . . . # # # # . # # # .
. # # . . . . . . # . . . # .
. . # . . . . . # . . . # . .
. . # . . . . # . . . . . # .
. . # . . . # # # # . # # # .
`)
for (let i = 0; i < img2.width() / 5; i++) {
    img2.showImage(i * 5)
    basic.pause(1000)
}

See also

show image, image, create image, scroll image, show animation

Edit this page on GitHub