Merge branch 'master' into icons

This commit is contained in:
Peli de Halleux 2017-11-16 22:47:40 -08:00 committed by GitHub
commit e400637ba1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 31 additions and 0 deletions

View File

@ -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.",

View File

@ -44,6 +44,7 @@
"brick.print|block": "`icons.brickDisplay` print %text| at x: %x| y: %y", "brick.print|block": "`icons.brickDisplay` print %text| at x: %x| y: %y",
"brick.setPixel|block": "`icons.brickDisplay` set pixel %on| at x: %x| y: %y", "brick.setPixel|block": "`icons.brickDisplay` set pixel %on| at x: %x| y: %y",
"brick.setStatusLight|block": "set `icons.brickButtons` to %pattern=led_pattern", "brick.setStatusLight|block": "set `icons.brickButtons` to %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",

View File

@ -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;