pxt-calliope/docs/reference/images/pixel.md
Thomas Denney 807e581c3d Addition of ignore notation
Some snippets are designed to show syntax errors or refer to earlier variables. In this case the automated checker needs to avoid compiling them
2016-08-10 13:43:48 +01:00

1.2 KiB

Pixel

The pixel function.

Get the state of a pixel in an Image.

JavaScript

export function pixel(_this: micro_bit.Image, x: number, y: number) : boolean

Parameters

  • x - Number; the x coordinate or horizontal position of a pixel in an image
  • y - Number; the y coordinate or vertical position of a pixel in an image

x, y coordinates?

To figure out the x, y coordinates, see LED screen.

Returns

  • Boolean - true for on and false for off

Example

This example gets the state of pixel 0, 0 in the img variable:

~hide

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

~

let state = img.pixel(0, 0)

See also

set pixel, show image, image, create image, scroll image