added showimage
This commit is contained in:
parent
f27fb4d93c
commit
b2768b1099
@ -20,6 +20,8 @@
|
|||||||
"brick.Button.onEvent": "Do something when a button or sensor is clicked, up or down.",
|
"brick.Button.onEvent": "Do something when a button or sensor is clicked, up or down.",
|
||||||
"brick.Button.onEvent|param|body": "code to run when the event is raised",
|
"brick.Button.onEvent|param|body": "code to run when the event is raised",
|
||||||
"brick.Button.wasPressed": "See if the button was pressed again since the last time you checked.",
|
"brick.Button.wasPressed": "See if the button was pressed again since the last time you checked.",
|
||||||
|
"brick._imagePicker": "An image",
|
||||||
|
"brick._imagePicker|param|image": "the image",
|
||||||
"brick.buttonDown": "Down button on the EV3 Brick.",
|
"brick.buttonDown": "Down button on the EV3 Brick.",
|
||||||
"brick.buttonEnter": "Enter button on the EV3 Brick.",
|
"brick.buttonEnter": "Enter button on the EV3 Brick.",
|
||||||
"brick.buttonLeft": "Left button on the EV3 Brick.",
|
"brick.buttonLeft": "Left button on the EV3 Brick.",
|
||||||
@ -37,6 +39,8 @@
|
|||||||
"brick.setPixel|param|y": "the starting position's x coordinate, eg: 0",
|
"brick.setPixel|param|y": "the starting position's x coordinate, eg: 0",
|
||||||
"brick.setStatusLight": "Set lights.",
|
"brick.setStatusLight": "Set lights.",
|
||||||
"brick.setStatusLight|param|pattern": "the lights pattern to use.",
|
"brick.setStatusLight|param|pattern": "the lights pattern to use.",
|
||||||
|
"brick.showImage": "Shows an image on screen",
|
||||||
|
"brick.showImage|param|image": "image to draw",
|
||||||
"control": "Program controls and events.",
|
"control": "Program controls and events.",
|
||||||
"control.allocateNotifyEvent": "Allocates the next user notification event",
|
"control.allocateNotifyEvent": "Allocates the next user notification event",
|
||||||
"control.deviceFirmwareVersion": "Determine the version of system software currently running.",
|
"control.deviceFirmwareVersion": "Determine the version of system software currently running.",
|
||||||
|
@ -35,6 +35,7 @@
|
|||||||
"brick.Button.isPressed|block": "%button|is pressed",
|
"brick.Button.isPressed|block": "%button|is pressed",
|
||||||
"brick.Button.onEvent|block": "on %button|%event",
|
"brick.Button.onEvent|block": "on %button|%event",
|
||||||
"brick.Button.wasPressed|block": "%button|was pressed",
|
"brick.Button.wasPressed|block": "%button|was pressed",
|
||||||
|
"brick._imagePicker|block": "%image",
|
||||||
"brick.buttonDown|block": "button down",
|
"brick.buttonDown|block": "button down",
|
||||||
"brick.buttonEnter|block": "button enter",
|
"brick.buttonEnter|block": "button enter",
|
||||||
"brick.buttonLeft|block": "button left",
|
"brick.buttonLeft|block": "button left",
|
||||||
@ -44,6 +45,7 @@
|
|||||||
"brick.print|block": "print %text| at x: %x| y: %y",
|
"brick.print|block": "print %text| at x: %x| y: %y",
|
||||||
"brick.setPixel|block": "set pixel %on| at x: %x| y: %y",
|
"brick.setPixel|block": "set pixel %on| at x: %x| y: %y",
|
||||||
"brick.setStatusLight|block": "set status light %pattern=led_pattern",
|
"brick.setStatusLight|block": "set status light %pattern=led_pattern",
|
||||||
|
"brick.showImage|block": "show image %image=scren_image_picker",
|
||||||
"brick|block": "brick",
|
"brick|block": "brick",
|
||||||
"control.raiseEvent|block": "raise event|from %src|with value %value",
|
"control.raiseEvent|block": "raise event|from %src|with value %value",
|
||||||
"control|block": "control",
|
"control|block": "control",
|
||||||
|
@ -133,6 +133,32 @@ namespace brick {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Shows an image on screen
|
||||||
|
* @param image image to draw
|
||||||
|
*/
|
||||||
|
//% blockId=screen_show_image block="show image %image=scren_image_picker"
|
||||||
|
//% weight=95 group="Screen" blockGap=8
|
||||||
|
export function showImage(image: Image, delay: number = 400) {
|
||||||
|
if (!image) return;
|
||||||
|
image.draw(0, 0, Draw.Normal);
|
||||||
|
delay = Math.max(0, delay);
|
||||||
|
loops.pause(delay);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An image
|
||||||
|
* @param image the image
|
||||||
|
*/
|
||||||
|
//% blockId=scren_image_picker block="%image" shim=TD_ID
|
||||||
|
//% image.fieldEditor="imagedropdown"
|
||||||
|
//% image.fieldOptions.columns=8
|
||||||
|
//% block.fieldOptions.hasSearchBar=true
|
||||||
|
//% group="Screen" weight=0 blockHidden=1
|
||||||
|
export function _imagePicker(image: Image): Image {
|
||||||
|
return image;
|
||||||
|
}
|
||||||
|
|
||||||
export function drawRect(x: number, y: number, w: number, h: number, mode = Draw.Normal) {
|
export function drawRect(x: number, y: number, w: number, h: number, mode = Draw.Normal) {
|
||||||
x |= 0;
|
x |= 0;
|
||||||
y |= 0;
|
y |= 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user