2.1.28, initiation update to PXT v5.28.24 (#54)
This commit is contained in:
committed by
Peli de Halleux
parent
38a964516e
commit
5c114a0c57
41
docs/reference/images/arrow-image.md
Normal file
41
docs/reference/images/arrow-image.md
Normal file
@ -0,0 +1,41 @@
|
||||
# arrow Image
|
||||
|
||||
Create an arrow shaped [image](/reference/images/image) for the [LED screen](/device/screen).
|
||||
|
||||
```sig
|
||||
images.arrowImage(ArrowNames.North)
|
||||
```
|
||||
|
||||
The arrow points in the direction of the arrow name you choose, like `North`.
|
||||
|
||||
## Parameters
|
||||
|
||||
* **i**: the arrow name to make an arrow [image](/reference/images/image) for. You can make an arrow image that points in one of these directions:
|
||||
|
||||
>* `North`
|
||||
>* `NorthEast`
|
||||
>* `East`
|
||||
>* `SouthEast`
|
||||
>* `South`
|
||||
>* `SouthWest`
|
||||
>* `West`
|
||||
>* `NorthWest`
|
||||
|
||||
## Example
|
||||
|
||||
Display a left arrow when button A is pressed or a right arrow when button B is pressed.
|
||||
|
||||
```blocks
|
||||
let arrowLeft = images.arrowImage(ArrowNames.West)
|
||||
let arrowRight = images.arrowImage(ArrowNames.East)
|
||||
|
||||
input.onButtonPressed(Button.A, () => {
|
||||
arrowLeft.showImage(0);
|
||||
});
|
||||
input.onButtonPressed(Button.B, () => {
|
||||
arrowRight.showImage(0);
|
||||
});
|
||||
```
|
||||
## See also
|
||||
|
||||
[arrow number](/reference/images/arrow-number)
|
33
docs/reference/images/arrow-number.md
Normal file
33
docs/reference/images/arrow-number.md
Normal file
@ -0,0 +1,33 @@
|
||||
# arrow Number
|
||||
|
||||
Get the number that matches an arrow image name.
|
||||
|
||||
```sig
|
||||
images.arrowNumber(ArrowNames.North)
|
||||
```
|
||||
|
||||
Each arrow image name has a number for it. You can find the number for any arrow name with ``||Images:arrow number||``.
|
||||
|
||||
## Parameters
|
||||
|
||||
* **arrow**: the arrow name to get an arrow number for. These are the arrow names:
|
||||
|
||||
>* `North`
|
||||
* `NorthEast`
|
||||
* `East`
|
||||
* `SouthEast`
|
||||
* `South`
|
||||
* `SouthWest`
|
||||
* `West`
|
||||
* `NorthWest`
|
||||
|
||||
## Example
|
||||
|
||||
Get the arrow number for `ArrowNames.South`.
|
||||
|
||||
```blocks
|
||||
let arrowSouthNumber = images.arrowNumber(ArrowNames.South)
|
||||
```
|
||||
## See also
|
||||
|
||||
[arrow image](/reference/images/arrow-image)
|
@ -14,13 +14,13 @@ images.createBigImage(`
|
||||
`);
|
||||
```
|
||||
|
||||
### Parameters
|
||||
## Parameters
|
||||
|
||||
* ``leds`` is a [string](/reference/types/string) that says which LEDs
|
||||
* ``leds`` is a [string](/types/string) that says which LEDs
|
||||
on the screen should be on and which should be off.
|
||||
|
||||
|
||||
### Example: Flip-flopping arrow
|
||||
## Example: Flip-flopping arrow
|
||||
|
||||
This program makes a big image with a picture of an arrow pointing up,
|
||||
and an arrow pointing down. If you press button `A`, the program will
|
||||
@ -44,9 +44,9 @@ input.onButtonPressed(Button.B, () => {
|
||||
});
|
||||
```
|
||||
|
||||
### See also
|
||||
## See also
|
||||
|
||||
[Getting Started](/getting-started), [image](/reference/images/image),
|
||||
[image](/reference/images/image),
|
||||
[create image](/reference/images/create-image),
|
||||
[show image](/reference/images/show-image),
|
||||
[scroll image](/reference/images/scroll-image), [show animation](/reference/basic/show-animation)
|
||||
|
@ -13,12 +13,12 @@ images.createImage(`
|
||||
`)
|
||||
```
|
||||
|
||||
### Parameters
|
||||
## Parameters
|
||||
|
||||
* ``leds`` is a [string](/reference/types/string) that says which LEDs
|
||||
* ``leds`` is a [string](/types/string) that says which LEDs
|
||||
on the screen should be on and which should be off.
|
||||
|
||||
### Example: Flip-flopping arrow
|
||||
## Example: Flip-flopping arrow
|
||||
|
||||
If you press button `A`, this program will make a picture of an
|
||||
arrow and show it on the LED screen. If you press button `B`, the
|
||||
@ -45,9 +45,9 @@ input.onButtonPressed(Button.B, () => {
|
||||
});
|
||||
```
|
||||
|
||||
### See also
|
||||
## See also
|
||||
|
||||
[Getting Started](/getting-started), [image](/reference/images/image),
|
||||
[image](/reference/images/image),
|
||||
[create big image](/reference/images/create-big-image),
|
||||
[show image](/reference/images/show-image),
|
||||
[scroll image](/reference/images/scroll-image), [show animation](/reference/basic/show-animation)
|
||||
|
33
docs/reference/images/icon-image.md
Normal file
33
docs/reference/images/icon-image.md
Normal file
@ -0,0 +1,33 @@
|
||||
# icon Image
|
||||
|
||||
Create an icon [image](/reference/images/image) for the [LED screen](/device/screen).
|
||||
|
||||
```sig
|
||||
images.iconImage(IconNames.Heart);
|
||||
```
|
||||
|
||||
There are lots of pre-made icon images you can use to display on the [LED screen](/device/screen) of the @boardname@. You choose an icon by its name.
|
||||
|
||||
## Parameters
|
||||
|
||||
* **i**: the icon name of the image you want to show on the [LED screen](/device/screen). You pick an icon image such as: `IconNames.Heart`.
|
||||
|
||||
## Example
|
||||
|
||||
Show a happy face when button A is pressed or a sad face when button B is pressed.
|
||||
|
||||
```blocks
|
||||
let iamHappy = images.iconImage(IconNames.Happy)
|
||||
let iamSad = images.iconImage(IconNames.Sad)
|
||||
|
||||
input.onButtonPressed(Button.A, () => {
|
||||
iamHappy.showImage(0);
|
||||
});
|
||||
input.onButtonPressed(Button.B, () => {
|
||||
iamSad.showImage(0);
|
||||
});
|
||||
```
|
||||
|
||||
## See also
|
||||
|
||||
[arrow image](/reference/images/arrow-image)
|
@ -2,11 +2,11 @@
|
||||
|
||||
An image for the @boardname@ screen.
|
||||
|
||||
### @parent blocks/language
|
||||
## @parent blocks/language
|
||||
|
||||
An *Image* is a matrix of pixels to show on the [LED screen](/device/screen)
|
||||
|
||||
### Block Editor: Show LEDs
|
||||
## Block Editor: Show LEDs
|
||||
|
||||
To display an image:
|
||||
|
||||
@ -22,7 +22,7 @@ basic.showLeds(`
|
||||
`)
|
||||
```
|
||||
|
||||
### Creating an image
|
||||
## Creating an image
|
||||
|
||||
To create an image that you can later modify, see the [create image](/reference/images/create-image) function.
|
||||
|
||||
@ -38,7 +38,7 @@ You should see code similar to this:
|
||||
|
||||

|
||||
|
||||
### Image functions
|
||||
## Image functions
|
||||
|
||||
* [create image](/reference/images/create-image): create an image from a series of on/off LED states
|
||||
* [clear](/reference/basic/clear-screen): turn off all the pixels in an image
|
||||
@ -47,7 +47,7 @@ You should see code similar to this:
|
||||
* [show image](/reference/images/show-image): show an image on the screen
|
||||
* [scroll image](/reference/images/scroll-image): scroll an image on the screen
|
||||
|
||||
### See also
|
||||
## See also
|
||||
|
||||
[Show LEDs](/reference/basic/show-leds), [create image](/reference/images/create-image), [show image](/reference/images/show-image), [LED screen](/device/screen)
|
||||
|
||||
|
@ -1,51 +1,41 @@
|
||||
# Pixel
|
||||
|
||||
The pixel function.
|
||||
|
||||
Get the state of a pixel in an [Image](/reference/images/image).
|
||||
|
||||
### JavaScript
|
||||
|
||||
## JavaScript
|
||||
|
||||
```sig
|
||||
export function pixel(_this: micro_bit.Image, x: number, y: number) : boolean
|
||||
let item: Image = null;
|
||||
item.pixel(0, 0)
|
||||
```
|
||||
## Parameters
|
||||
|
||||
### Parameters
|
||||
* x - [Number](/types/number); the *x coordinate* or horizontal position of a pixel in an [image](/reference/images/image)
|
||||
* y - [Number](/types/number); the *y coordinate* or vertical position of a pixel in an [image](/reference/images/image)
|
||||
|
||||
* x - [Number](/reference/types/number); the *x coordinate* or horizontal position of a pixel in an [image](/reference/images/image)
|
||||
* y - [Number](/reference/types/number); the *y coordinate* or vertical position of a pixel in an [image](/reference/images/image)
|
||||
|
||||
### x, y coordinates?
|
||||
## x, y coordinates?
|
||||
|
||||
To figure out the ``x``, ``y`` coordinates, see [LED screen](/device/screen).
|
||||
|
||||
### Returns
|
||||
## Returns
|
||||
|
||||
* [Boolean](/blocks/logic/boolean) - `true` for on and `false` for off
|
||||
|
||||
### Example
|
||||
## Example
|
||||
|
||||
This example gets the state of pixel `0, 0` in the `img` variable:
|
||||
|
||||
### ~hide
|
||||
|
||||
```blocks
|
||||
let img = images.createImage(`
|
||||
. . # . . . . . . .
|
||||
. # . # . . . # . .
|
||||
. . # . . . . . . .
|
||||
. # . # . . . # . .
|
||||
. . # . . . . . . .
|
||||
. # . # . . . # . .. . # . . . . . . .
|
||||
`)
|
||||
```
|
||||
|
||||
### ~
|
||||
|
||||
```typescript-ignore
|
||||
let state = img.pixel(0, 0)
|
||||
```
|
||||
|
||||
### See also
|
||||
|
||||
[set pixel](/reference/images/set-pixel), [show image](/reference/images/show-image), [image](/reference/images/image), [create image](/reference/images/create-image), [scroll image](/reference/images/scroll-image)
|
||||
## See also
|
||||
|
||||
[set pixel](/reference/images/set-pixel), [show image](/reference/images/show-image), [image](/reference/images/image), [create image](/reference/images/create-image), [scroll image](/reference/images/scroll-image)
|
@ -4,21 +4,21 @@ The plot frame function.
|
||||
|
||||
Display an [Image](/reference/images/image) on the @boardname@'s [LED screen](/device/screen)
|
||||
|
||||
### JavaScript
|
||||
## JavaScript
|
||||
|
||||
```sig
|
||||
export function plotFrame(_this: micro_bit.Image, index: number)
|
||||
```
|
||||
|
||||
### Parameters
|
||||
## Parameters
|
||||
|
||||
* index - [Number](/reference/types/number); which frame of the image to display
|
||||
* index - [Number](/types/number); which frame of the image to display
|
||||
|
||||
### Difference from `plot image`
|
||||
## Difference from `plot image`
|
||||
|
||||
The `plot frame` function takes the index of the frame (if there are two frames, then the possible indices are 0 and 1), whereas `plot image` accepts an offset (if there are two frames, the offset would range between 0 and 9).
|
||||
|
||||
### Example
|
||||
## Example
|
||||
|
||||
```blocks
|
||||
let img = images.createImage(`
|
||||
@ -31,7 +31,7 @@ let img = images.createImage(`
|
||||
img.plotFrame(1)
|
||||
```
|
||||
|
||||
### See also
|
||||
## See also
|
||||
|
||||
[create image](/reference/images/create-image), [show animation](/reference/basic/show-animation), [image](/reference/images/image), [show image](/reference/images/show-image), [scroll image](/reference/images/scroll-image)
|
||||
|
||||
|
@ -4,21 +4,21 @@ The plot image function.
|
||||
|
||||
Display an [Image](/reference/images/image) on the @boardname@'s [LED screen](/device/screen)
|
||||
|
||||
### JavaScript
|
||||
## JavaScript
|
||||
|
||||
```sig
|
||||
export function plotImage(_this: micro_bit.Image, xOffset: number)
|
||||
```
|
||||
|
||||
### Parameters
|
||||
## Parameters
|
||||
|
||||
* x offset - [Number](/reference/types/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.
|
||||
* x offset - [Number](/types/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.
|
||||
|
||||
### Difference from `show image`
|
||||
## Difference from `show image`
|
||||
|
||||
The `show image` function has a built in delay of 400ms after display of the image, whereas `plot image` has no built-in delay.
|
||||
|
||||
### Example
|
||||
## Example
|
||||
|
||||
```blocks
|
||||
let img = images.createImage(`
|
||||
@ -31,7 +31,7 @@ let img = images.createImage(`
|
||||
img.plotImage(0)
|
||||
```
|
||||
|
||||
### See also
|
||||
## See also
|
||||
|
||||
[create image](/reference/images/create-image), [show animation](/reference/basic/show-animation), [image](/reference/images/image), [show image](/reference/images/show-image), [scroll image](/reference/images/scroll-image)
|
||||
|
||||
|
@ -8,24 +8,21 @@ let item: Image = null;
|
||||
item.scrollImage(5, 200);
|
||||
```
|
||||
|
||||
### Parameters
|
||||
## Parameters
|
||||
|
||||
* a [number](/reference/types/number) that means
|
||||
how many LEDs to scroll at a time, from right to left or
|
||||
left to right. If you use a positive number like `2`, the image
|
||||
will scroll from the right side of the screen to the left.
|
||||
If you use a negative number like `-2`, the image will scroll
|
||||
in the other direction. If you use `5` or `-5`, the image
|
||||
will scroll one **frame** at a time. (A frame is a part of the
|
||||
image. It is a square with five LEDs on a side). This is
|
||||
useful for **animation**.
|
||||
* a [number](/types/number) that means
|
||||
how many LEDs to scroll at a time from right to left.
|
||||
You must use a positive number like `2`.
|
||||
If you use `5`, the image will scroll one **frame** at a time.
|
||||
(A frame is a part of the image. It is a square with five LEDs
|
||||
on a side). This is useful for **animation**.
|
||||
|
||||
* a [number](/reference/types/number) that means
|
||||
* a [number](/types/number) that means
|
||||
how many milliseconds to wait before scrolling the amount that
|
||||
``offset`` says. (1000 milliseconds is one second.) The bigger you
|
||||
make this number, the slower the image will scroll.
|
||||
|
||||
### Example
|
||||
## Example
|
||||
|
||||
This program scrolls an image of two arrows five LEDs at a time,
|
||||
with a pause of 200 milliseconds between each time it scrolls.
|
||||
@ -47,7 +44,7 @@ basic.forever(() => {
|
||||
});
|
||||
```
|
||||
|
||||
### See also
|
||||
## See also
|
||||
|
||||
[show image](/reference/images/show-image), [image](/reference/images/image), [create image](/reference/images/create-image), [show animation](/reference/basic/show-animation)
|
||||
|
||||
|
@ -1,28 +1,27 @@
|
||||
# Set Pixel
|
||||
|
||||
The set pixel function. #set pixel.
|
||||
|
||||
Set the on/off state of pixel in an [Image](/reference/images/image).
|
||||
|
||||
### JavaScript
|
||||
## JavaScript
|
||||
|
||||
```sig
|
||||
export function setPixel(_this: micro_bit.Image, x: number, y: number, value: boolean)
|
||||
let item: Image = null;
|
||||
item.setPixel(0, 0, true)
|
||||
```
|
||||
|
||||
### Parameters
|
||||
## Parameters
|
||||
|
||||
* x - [Number](/reference/types/number); the *x coordinate* or horizontal position of a pixel in an [image](/reference/images/image)
|
||||
* x - [Number](/reference/types/number); the *y coordinate* or vertical position of a pixel in an [image](/reference/images/image)
|
||||
* x - [Number](/types/number); the *x coordinate* or horizontal position of a pixel in an [image](/reference/images/image)
|
||||
* y - [Number](/types/number); the *y coordinate* or vertical position of a pixel in an [image](/reference/images/image)
|
||||
* value -[Boolean](/blocks/logic/boolean); the on/off state of a pixel; `true` for on, `false` for off
|
||||
|
||||
### x, y coordinates?
|
||||
## x, y coordinates?
|
||||
|
||||
To figure out the ``x``, ``y`` coordinates, see [LED screen](/device/screen).
|
||||
|
||||
### Example
|
||||
## Example
|
||||
|
||||
The following example creates an image and stores it in the `img` variable. The `set pixel` function sets the centre pixel off, before `img` is shown using `show image`.
|
||||
The following example creates an image and stores it in the `img` variable. The `set pixel` function sets the center pixel off, before `img` is shown using `show image`.
|
||||
|
||||
```blocks
|
||||
let img = images.createImage(`
|
||||
@ -35,8 +34,6 @@ let img = images.createImage(`
|
||||
img.setPixel(2, 2, false)
|
||||
img.showImage(0)
|
||||
```
|
||||
## See also
|
||||
|
||||
### See also
|
||||
|
||||
[pixel](/reference/images/pixel), [show image](/reference/images/show-image), [image](/reference/images/image), [create image](/reference/images/create-image), [scroll image](/reference/images/scroll-image)
|
||||
|
||||
[pixel](/reference/images/pixel), [show image](/reference/images/show-image), [image](/reference/images/image), [create image](/reference/images/create-image), [scroll image](/reference/images/scroll-image)
|
@ -4,21 +4,21 @@ The show frame function.
|
||||
|
||||
Display an [Image](/reference/images/image) on the @boardname@'s [LED screen](/device/screen)
|
||||
|
||||
### JavaScript
|
||||
## JavaScript
|
||||
|
||||
```sig
|
||||
export function showFrame(img: micro_bit.Image, frame: number)
|
||||
```
|
||||
|
||||
### Parameters
|
||||
## Parameters
|
||||
|
||||
* index - [Number](/reference/types/number); which frame of the image to display
|
||||
* index - [Number](/types/number); which frame of the image to display
|
||||
|
||||
### Difference from `plot frame`
|
||||
## Difference from `plot frame`
|
||||
|
||||
The `show frame` function is the same as [plot frame](/reference/images/plot-frame), but contains a built-in delay after the LED screen has been updated (whereas `plot frame` has no built-in delay)
|
||||
|
||||
### Example
|
||||
## Example
|
||||
|
||||
```blocks
|
||||
let img = images.createImage(`
|
||||
@ -31,7 +31,7 @@ let img = images.createImage(`
|
||||
img.showFrame(1)
|
||||
```
|
||||
|
||||
### See also
|
||||
## See also
|
||||
|
||||
[create image](/reference/images/create-image), [show animation](/reference/basic/show-animation), [image](/reference/images/image), [show image](/reference/images/show-image), [scroll image](/reference/images/scroll-image)
|
||||
|
||||
|
@ -9,12 +9,12 @@ let item: Image = null;
|
||||
item.showImage(0);
|
||||
```
|
||||
|
||||
### Parameters
|
||||
## Parameters
|
||||
|
||||
* an [image](/reference/images/image) (picture). It is usually a square with five LEDs on a side, but it might be wider.
|
||||
* a [number](/reference/types/number) that says how many LEDs from the left of the picture the @boardname@ should start. `0` means start at the first **frame** of the picture, `5` means start at the second frame, `10` means start at the third, and so on.
|
||||
* a [number](/types/number) that says how many LEDs from the left of the picture the @boardname@ should start. `0` means start at the first **frame** of the picture, `5` means start at the second frame, `10` means start at the third, and so on.
|
||||
|
||||
### Example: Flip-flopping arrow
|
||||
## Example: Flip-flopping arrow
|
||||
|
||||
This program makes a big image with a frame of an arrow pointing up,
|
||||
and a frame of an arrow pointing down. If you press button `A`, the
|
||||
@ -39,9 +39,9 @@ input.onButtonPressed(Button.B, () => {
|
||||
});
|
||||
```
|
||||
|
||||
### See also
|
||||
## See also
|
||||
|
||||
[Getting Started](/getting-started), [image](/reference/images/image),
|
||||
[image](/reference/images/image),
|
||||
[create image](/reference/images/create-image),
|
||||
[create big image](/reference/images/create-big-image),
|
||||
[scroll image](/reference/images/scroll-image), [show animation](/reference/basic/show-animation)
|
||||
|
@ -8,17 +8,13 @@ Get the width of an [Image](/reference/images/image) in columns.
|
||||
images.createImage().width();
|
||||
```
|
||||
|
||||
### Parameters
|
||||
## Returns
|
||||
|
||||
* none
|
||||
|
||||
### Returns
|
||||
|
||||
* [Number](/reference/types/number) - the number of columns in a image. This function returns 5 if the image has 1 frame, 10 for 2 frames, 15 for 3 frames and so on. Divide the number of columns by 5 to find out how many frames an image has (see example below).
|
||||
* [Number](/types/number) - the number of columns in a image. This function returns 5 if the image has 1 frame, 10 for 2 frames, 15 for 3 frames and so on. Divide the number of columns by 5 to find out how many frames an image has (see example below).
|
||||
|
||||
The following example gets the width of `img` and stores it in the `w` variable:
|
||||
|
||||
### ~hide
|
||||
## ~hide
|
||||
|
||||
```blocks
|
||||
let img = images.createImage(`
|
||||
@ -30,13 +26,13 @@ let img = images.createImage(`
|
||||
`)
|
||||
```
|
||||
|
||||
### ~
|
||||
## ~
|
||||
|
||||
```typescript-ignore
|
||||
let w = img.width()
|
||||
```
|
||||
|
||||
### Example: show each frame
|
||||
## Example: show each frame
|
||||
|
||||
The following example uses the `width` function with a [for](/blocks/loops/for) loop to show each image frame on the screen:
|
||||
|
||||
@ -54,7 +50,7 @@ for (let i = 0; i < img2.width() / 5; i++) {
|
||||
}
|
||||
```
|
||||
|
||||
### See also
|
||||
## See also
|
||||
|
||||
[show image](/reference/images/show-image), [image](/reference/images/image), [create image](/reference/images/create-image), [scroll image](/reference/images/scroll-image), [show animation](/reference/basic/show-animation)
|
||||
|
||||
|
Reference in New Issue
Block a user