support for icons (#15)
@ -139,7 +139,12 @@
|
|||||||
"basic.showAnimation": "Shows a sequence of LED screens as an animation.",
|
"basic.showAnimation": "Shows a sequence of LED screens as an animation.",
|
||||||
"basic.showAnimation|param|interval": "time in milliseconds between each redraw",
|
"basic.showAnimation|param|interval": "time in milliseconds between each redraw",
|
||||||
"basic.showAnimation|param|leds": "pattern of LEDs to turn on/off",
|
"basic.showAnimation|param|leds": "pattern of LEDs to turn on/off",
|
||||||
|
"basic.showArrow": "Shows an arrow on screent",
|
||||||
|
"basic.showArrow|param|direction": "the direction of the arrow",
|
||||||
|
"basic.showArrow|param|interval": "the amount of time (milliseconds) to show the icon. Default is 600.",
|
||||||
"basic.showIcon": "Draws the selected icon on the LED screen",
|
"basic.showIcon": "Draws the selected icon on the LED screen",
|
||||||
|
"basic.showIcon|param|icon": "the predifined icon id",
|
||||||
|
"basic.showIcon|param|interval": "the amount of time (milliseconds) to show the icon. Default is 600.",
|
||||||
"basic.showLeds": "Draws an image on the LED screen.",
|
"basic.showLeds": "Draws an image on the LED screen.",
|
||||||
"basic.showLeds|param|interval": "time in milliseconds to pause after drawing",
|
"basic.showLeds|param|interval": "time in milliseconds to pause after drawing",
|
||||||
"basic.showLeds|param|leds": "the pattern of LED to turn on/off",
|
"basic.showLeds|param|leds": "the pattern of LED to turn on/off",
|
||||||
|
@ -17,6 +17,14 @@
|
|||||||
"Array.shift|block": "get and remove first value from %list",
|
"Array.shift|block": "get and remove first value from %list",
|
||||||
"Array.unshift|block": "%list| insert %value| at beginning",
|
"Array.unshift|block": "%list| insert %value| at beginning",
|
||||||
"Array|block": "Array",
|
"Array|block": "Array",
|
||||||
|
"ArrowNames.East|block": "East",
|
||||||
|
"ArrowNames.NorthEast|block": "North East",
|
||||||
|
"ArrowNames.NorthWest|block": "North West",
|
||||||
|
"ArrowNames.North|block": "North",
|
||||||
|
"ArrowNames.SouthEast|block": "South East",
|
||||||
|
"ArrowNames.SouthWest|block": "South West",
|
||||||
|
"ArrowNames.South|block": "South",
|
||||||
|
"ArrowNames.West|block": "West",
|
||||||
"BaudRate.BaudRate115200|block": "115200",
|
"BaudRate.BaudRate115200|block": "115200",
|
||||||
"BaudRate.BaudRate56700|block": "57600",
|
"BaudRate.BaudRate56700|block": "57600",
|
||||||
"BaudRate.BaudRate9600|block": "9600",
|
"BaudRate.BaudRate9600|block": "9600",
|
||||||
@ -93,12 +101,12 @@
|
|||||||
"IconNames.LeftTriangle|block": "left triangle",
|
"IconNames.LeftTriangle|block": "left triangle",
|
||||||
"IconNames.Meh|block": "meh",
|
"IconNames.Meh|block": "meh",
|
||||||
"IconNames.No|block": "no",
|
"IconNames.No|block": "no",
|
||||||
"IconNames.Pacman|block": "pac man",
|
|
||||||
"IconNames.Pitchfork|block": "pitchfork",
|
"IconNames.Pitchfork|block": "pitchfork",
|
||||||
"IconNames.QuarterNote|block": "quarter note",
|
"IconNames.QuarterNote|block": "quarter note",
|
||||||
"IconNames.Rabbit|block": "rabbit",
|
"IconNames.Rabbit|block": "rabbit",
|
||||||
"IconNames.Rollerskate|block": "roller skate",
|
"IconNames.Rollerskate|block": "roller skate",
|
||||||
"IconNames.Sad|block": "sad",
|
"IconNames.Sad|block": "sad",
|
||||||
|
"IconNames.Scissors|block": "scissors",
|
||||||
"IconNames.Silly|block": "silly",
|
"IconNames.Silly|block": "silly",
|
||||||
"IconNames.Skull|block": "skull",
|
"IconNames.Skull|block": "skull",
|
||||||
"IconNames.SmallDiamond|block": "small diamond",
|
"IconNames.SmallDiamond|block": "small diamond",
|
||||||
|
@ -27,103 +27,143 @@ THE SOFTWARE.
|
|||||||
|
|
||||||
enum IconNames {
|
enum IconNames {
|
||||||
//% block="heart"
|
//% block="heart"
|
||||||
|
//% blockImage=1
|
||||||
Heart = 0,
|
Heart = 0,
|
||||||
//% block="small heart"
|
//% block="small heart"
|
||||||
|
//% blockImage=1
|
||||||
SmallHeart,
|
SmallHeart,
|
||||||
//% block="yes"
|
//% block="yes"
|
||||||
|
//% blockImage=1
|
||||||
Yes,
|
Yes,
|
||||||
//% block="no"
|
//% block="no"
|
||||||
|
//% blockImage=1
|
||||||
No,
|
No,
|
||||||
//% block="happy"
|
//% block="happy"
|
||||||
|
//% blockImage=1
|
||||||
Happy,
|
Happy,
|
||||||
//% block="sad"
|
//% block="sad"
|
||||||
|
//% blockImage=1
|
||||||
Sad,
|
Sad,
|
||||||
//% block="confused"
|
//% block="confused"
|
||||||
|
//% blockImage=1
|
||||||
Confused,
|
Confused,
|
||||||
//% block="angry"
|
//% block="angry"
|
||||||
|
//% blockImage=1
|
||||||
Angry,
|
Angry,
|
||||||
//% block="asleep"
|
//% block="asleep"
|
||||||
|
//% blockImage=1
|
||||||
Asleep,
|
Asleep,
|
||||||
//% block="surprised"
|
//% block="surprised"
|
||||||
|
//% blockImage=1
|
||||||
Surprised,
|
Surprised,
|
||||||
//% block="silly"
|
//% block="silly"
|
||||||
|
//% blockImage=1
|
||||||
Silly,
|
Silly,
|
||||||
//% block="fabulous"
|
//% block="fabulous"
|
||||||
|
//% blockImage=1
|
||||||
Fabulous,
|
Fabulous,
|
||||||
//% block="meh"
|
//% block="meh"
|
||||||
|
//% blockImage=1
|
||||||
Meh,
|
Meh,
|
||||||
//% block="t-shirt"
|
//% block="t-shirt"
|
||||||
|
//% blockImage=1
|
||||||
TShirt,
|
TShirt,
|
||||||
//% block="roller skate"
|
//% block="roller skate"
|
||||||
|
//% blockImage=1
|
||||||
Rollerskate,
|
Rollerskate,
|
||||||
//% block="duck"
|
//% block="duck"
|
||||||
|
//% blockImage=1
|
||||||
Duck,
|
Duck,
|
||||||
//% block="house"
|
//% block="house"
|
||||||
|
//% blockImage=1
|
||||||
House,
|
House,
|
||||||
//% block="tortoise"
|
//% block="tortoise"
|
||||||
|
//% blockImage=1
|
||||||
Tortoise,
|
Tortoise,
|
||||||
//% block="butterfly"
|
//% block="butterfly"
|
||||||
|
//% blockImage=1
|
||||||
Butterfly,
|
Butterfly,
|
||||||
//% block="stick figure"
|
//% block="stick figure"
|
||||||
|
//% blockImage=1
|
||||||
StickFigure,
|
StickFigure,
|
||||||
//% block="ghost"
|
//% block="ghost"
|
||||||
|
//% blockImage=1
|
||||||
Ghost,
|
Ghost,
|
||||||
//% block="sword"
|
//% block="sword"
|
||||||
|
//% blockImage=1
|
||||||
Sword,
|
Sword,
|
||||||
//% block="giraffe"
|
//% block="giraffe"
|
||||||
|
//% blockImage=1
|
||||||
Giraffe,
|
Giraffe,
|
||||||
//% block="skull"
|
//% block="skull"
|
||||||
|
//% blockImage=1
|
||||||
Skull,
|
Skull,
|
||||||
//% block="umbrella"
|
//% block="umbrella"
|
||||||
|
//% blockImage=1
|
||||||
Umbrella,
|
Umbrella,
|
||||||
//% block="snake"
|
//% block="snake"
|
||||||
|
//% blockImage=1
|
||||||
Snake,
|
Snake,
|
||||||
//% block="rabbit"
|
//% block="rabbit"
|
||||||
|
//% blockImage=1
|
||||||
Rabbit,
|
Rabbit,
|
||||||
//% block="cow"
|
//% block="cow"
|
||||||
|
//% blockImage=1
|
||||||
Cow,
|
Cow,
|
||||||
//% block="quarter note"
|
//% block="quarter note"
|
||||||
|
//% blockImage=1
|
||||||
QuarterNote,
|
QuarterNote,
|
||||||
//% block="eigth note"
|
//% block="eigth note"
|
||||||
|
//% blockImage=1
|
||||||
EigthNote,
|
EigthNote,
|
||||||
//% block="pitchfork"
|
//% block="pitchfork"
|
||||||
|
//% blockImage=1
|
||||||
Pitchfork,
|
Pitchfork,
|
||||||
//% block="pac man"
|
|
||||||
Pacman,
|
|
||||||
//% block="target"
|
//% block="target"
|
||||||
|
//% blockImage=1
|
||||||
Target,
|
Target,
|
||||||
//% block="triangle"
|
//% block="triangle"
|
||||||
|
//% blockImage=1
|
||||||
Triangle,
|
Triangle,
|
||||||
//% block="left triangle"
|
//% block="left triangle"
|
||||||
|
//% blockImage=1
|
||||||
LeftTriangle,
|
LeftTriangle,
|
||||||
//% block="chess board"
|
//% block="chess board"
|
||||||
|
//% blockImage=1
|
||||||
Chessboard,
|
Chessboard,
|
||||||
//% block="diamond"
|
//% block="diamond"
|
||||||
|
//% blockImage=1
|
||||||
Diamond,
|
Diamond,
|
||||||
//% block="small diamond"
|
//% block="small diamond"
|
||||||
|
//% blockImage=1
|
||||||
SmallDiamond,
|
SmallDiamond,
|
||||||
//% block="square"
|
//% block="square"
|
||||||
|
//% blockImage=1
|
||||||
Square,
|
Square,
|
||||||
//% block="small square"
|
//% block="small square"
|
||||||
|
//% blockImage=1
|
||||||
SmallSquare,
|
SmallSquare,
|
||||||
|
//% block="scissors"
|
||||||
|
//% blockImage=1
|
||||||
|
Scissors
|
||||||
}
|
}
|
||||||
|
|
||||||
enum ArrowNames {
|
enum ArrowNames {
|
||||||
//% blockIdentity=images.arrowNumber
|
//% blockIdentity=images.arrowNumber block="North"
|
||||||
North = 0,
|
North = 0,
|
||||||
//% blockIdentity=images.arrowNumber
|
//% blockIdentity=images.arrowNumber block="North East"
|
||||||
NorthEast,
|
NorthEast,
|
||||||
//% blockIdentity=images.arrowNumber
|
//% blockIdentity=images.arrowNumber block="East"
|
||||||
East,
|
East,
|
||||||
//% blockIdentity=images.arrowNumber
|
//% blockIdentity=images.arrowNumber block="South East"
|
||||||
SouthEast,
|
SouthEast,
|
||||||
//% blockIdentity=images.arrowNumber
|
//% blockIdentity=images.arrowNumber block="South"
|
||||||
South,
|
South,
|
||||||
//% blockIdentity=images.arrowNumber
|
//% blockIdentity=images.arrowNumber block="South West"
|
||||||
SouthWest,
|
SouthWest,
|
||||||
//% blockIdentity=images.arrowNumber
|
//% blockIdentity=images.arrowNumber block="West"
|
||||||
West,
|
West,
|
||||||
//% blockIdentity=images.arrowNumber
|
//% blockIdentity=images.arrowNumber block="North West"
|
||||||
NorthWest,
|
NorthWest,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -131,393 +171,376 @@ namespace basic {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Draws the selected icon on the LED screen
|
* Draws the selected icon on the LED screen
|
||||||
|
* @param icon the predifined icon id
|
||||||
|
* @param interval the amount of time (milliseconds) to show the icon. Default is 600.
|
||||||
*/
|
*/
|
||||||
//% weight=90 blockGap=8
|
//% weight=90 blockGap=8
|
||||||
//% blockId=basic_show_icon
|
//% blockId=basic_show_icon
|
||||||
//% block="show icon %i" icon="\uf00a"
|
//% block="show icon %i" icon="\uf00a"
|
||||||
//% parts="ledmatrix"
|
//% parts="ledmatrix"
|
||||||
//% help=basic/show-icon
|
//% help=basic/show-icon
|
||||||
export function showIcon(icon: IconNames) {
|
//% i.fieldEditor="gridpicker"
|
||||||
|
//% i.fieldOptions.width="400" i.fieldOptions.columns="5"
|
||||||
|
//% i.fieldOptions.itemColour="black" i.fieldOptions.tooltips="true"
|
||||||
|
export function showIcon(icon: IconNames, interval = 600) {
|
||||||
let res = images.iconImage(icon)
|
let res = images.iconImage(icon)
|
||||||
res.showImage(0)
|
res.showImage(0, interval)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Shows an arrow on screent
|
||||||
|
* @param direction the direction of the arrow
|
||||||
|
* @param interval the amount of time (milliseconds) to show the icon. Default is 600.
|
||||||
|
*/
|
||||||
//% weight=50 blockGap=8
|
//% weight=50 blockGap=8
|
||||||
//% blockId=basic_show_arrow
|
//% blockId=basic_show_arrow
|
||||||
//% block="show arrow %i=device_arrow"
|
//% block="show arrow %i=device_arrow"
|
||||||
//% parts="ledmatrix"
|
//% parts="ledmatrix"
|
||||||
//% advanced=true
|
//% advanced=true
|
||||||
//% help=basic/show-arrow
|
//% help=basic/show-arrow
|
||||||
export function showArrow(i: number) {
|
export function showArrow(direction: number, interval = 600) {
|
||||||
let res = images.arrowImage(i)
|
let res = images.arrowImage(direction)
|
||||||
res.showImage(0)
|
res.showImage(0, interval)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
namespace images {
|
namespace images {
|
||||||
|
|
||||||
function getArrow(i : ArrowNames): string {
|
//% weight=50 blockGap=8
|
||||||
|
//% help=images/arrow-image
|
||||||
|
//% blockId=builtin_arrow_image block="arrow image %i=device_arrow"
|
||||||
|
export function arrowImage(i: ArrowNames): Image {
|
||||||
switch (i) {
|
switch (i) {
|
||||||
// compass directions
|
// compass directions
|
||||||
case ArrowNames.North: return `
|
case ArrowNames.North: return images.createImage(`
|
||||||
. . # . .
|
. . # . .
|
||||||
. # # # .
|
. # # # .
|
||||||
# . # . #
|
# . # . #
|
||||||
. . # . .
|
. . # . .
|
||||||
. . # . .`;
|
. . # . .`);
|
||||||
case ArrowNames.NorthEast: return `
|
case ArrowNames.NorthEast: return images.createImage(`
|
||||||
. . # # #
|
. . # # #
|
||||||
. . . # #
|
. . . # #
|
||||||
. . # . #
|
. . # . #
|
||||||
. # . . .
|
. # . . .
|
||||||
# . . . .`;
|
# . . . .`);
|
||||||
case ArrowNames.East: return `
|
case ArrowNames.East: return images.createImage(`
|
||||||
. . # . .
|
. . # . .
|
||||||
. . . # .
|
. . . # .
|
||||||
# # # # #
|
# # # # #
|
||||||
. . . # .
|
. . . # .
|
||||||
. . # . .`;
|
. . # . .`);
|
||||||
case ArrowNames.SouthEast: return `
|
case ArrowNames.SouthEast: return images.createImage(`
|
||||||
# . . . .
|
# . . . .
|
||||||
. # . . .
|
. # . . .
|
||||||
. . # . #
|
. . # . #
|
||||||
. . . # #
|
. . . # #
|
||||||
. . # # #`;
|
. . # # #`);
|
||||||
case ArrowNames.South: return `
|
case ArrowNames.South: return images.createImage(`
|
||||||
. . # . .
|
. . # . .
|
||||||
. . # . .
|
. . # . .
|
||||||
# . # . #
|
# . # . #
|
||||||
. # # # .
|
. # # # .
|
||||||
. . # . .`;
|
. . # . .`);
|
||||||
case ArrowNames.SouthWest: return `
|
case ArrowNames.SouthWest: return images.createImage(`
|
||||||
. . . . #
|
. . . . #
|
||||||
. . . # .
|
. . . # .
|
||||||
# . # . .
|
# . # . .
|
||||||
# # . . .
|
# # . . .
|
||||||
# # # . .`;
|
# # # . .`);
|
||||||
case ArrowNames.West: return `
|
case ArrowNames.West: return images.createImage(`
|
||||||
. . # . .
|
. . # . .
|
||||||
. # . . .
|
. # . . .
|
||||||
# # # # #
|
# # # # #
|
||||||
. # . . .
|
. # . . .
|
||||||
. . # . .`;
|
. . # . .`);
|
||||||
case ArrowNames.NorthWest: return `
|
case ArrowNames.NorthWest: return images.createImage(`
|
||||||
# # # . .
|
# # # . .
|
||||||
# # . . .
|
# # . . .
|
||||||
# . # . .
|
# . # . .
|
||||||
. . . # .
|
. . . # .
|
||||||
. . . . #`;
|
. . . . #`);
|
||||||
default: return `
|
default: return images.createImage(`
|
||||||
. . . . .
|
. . . . .
|
||||||
. . . . .
|
. . . . .
|
||||||
. . . . .
|
. . . . .
|
||||||
. . . . .
|
. . . . .
|
||||||
. . . . .
|
. . . . .
|
||||||
`;
|
`);
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function getIcon(i: IconNames): string {
|
|
||||||
|
|
||||||
switch (i) {
|
|
||||||
case IconNames.Heart : return `
|
|
||||||
. # . # .
|
|
||||||
# # # # #
|
|
||||||
# # # # #
|
|
||||||
. # # # .
|
|
||||||
. . # . .`;
|
|
||||||
|
|
||||||
case IconNames.SmallHeart : return `
|
|
||||||
. . . . .
|
|
||||||
. # . # .
|
|
||||||
. # # # .
|
|
||||||
. . # . .
|
|
||||||
. . . . .`;
|
|
||||||
//faces
|
|
||||||
case IconNames.Happy: return `
|
|
||||||
. . . . .
|
|
||||||
. # . # .
|
|
||||||
. . . . .
|
|
||||||
# . . . #
|
|
||||||
. # # # .`;
|
|
||||||
case IconNames.Sad: return `
|
|
||||||
. . . . .
|
|
||||||
. # . # .
|
|
||||||
. . . . .
|
|
||||||
. # # # .
|
|
||||||
# . . . #`;
|
|
||||||
case IconNames.Confused: return `
|
|
||||||
. . . . .
|
|
||||||
. # . # .
|
|
||||||
. . . . .
|
|
||||||
. # . # .
|
|
||||||
# . # . #`;
|
|
||||||
case IconNames.Angry: return `
|
|
||||||
# . . . #
|
|
||||||
. # . # .
|
|
||||||
. . . . .
|
|
||||||
# # # # #
|
|
||||||
# . # . #`;
|
|
||||||
case IconNames.Asleep: return `
|
|
||||||
. . . . .
|
|
||||||
# # . # #
|
|
||||||
. . . . .
|
|
||||||
. # # # .
|
|
||||||
. . . . .`;
|
|
||||||
case IconNames.Surprised: return `
|
|
||||||
. # . # .
|
|
||||||
. . . . .
|
|
||||||
. . # . .
|
|
||||||
. # . # .
|
|
||||||
. . # . .`;
|
|
||||||
case IconNames.Silly: return `
|
|
||||||
# . . . #
|
|
||||||
. . . . .
|
|
||||||
# # # # #
|
|
||||||
. . . # #
|
|
||||||
. . . # #`;
|
|
||||||
case IconNames.Fabulous: return `
|
|
||||||
# # # # #
|
|
||||||
# # . # #
|
|
||||||
. . . . .
|
|
||||||
. # . # .
|
|
||||||
. # # # .`;
|
|
||||||
case IconNames.Meh: return `
|
|
||||||
# # . # #
|
|
||||||
. . . . .
|
|
||||||
. . . # .
|
|
||||||
. . # . .
|
|
||||||
. # . . .`;
|
|
||||||
case IconNames.Yes: return `
|
|
||||||
. . . . .
|
|
||||||
. . . . #
|
|
||||||
. . . # .
|
|
||||||
# . # . .
|
|
||||||
. # . . .`;
|
|
||||||
case IconNames.No: return `
|
|
||||||
# . . . #
|
|
||||||
. # . # .
|
|
||||||
. . # . .
|
|
||||||
. # . # .
|
|
||||||
# . . . #`;
|
|
||||||
case IconNames.Triangle: return `
|
|
||||||
. . . . .
|
|
||||||
. . # . .
|
|
||||||
. # . # .
|
|
||||||
# # # # #
|
|
||||||
. . . . .`;
|
|
||||||
case IconNames.LeftTriangle: return `
|
|
||||||
# . . . .
|
|
||||||
# # . . .
|
|
||||||
# . # . .
|
|
||||||
# . . # .
|
|
||||||
# # # # #`;
|
|
||||||
case IconNames.Chessboard: return `
|
|
||||||
. # . # .
|
|
||||||
# . # . #
|
|
||||||
. # . # .
|
|
||||||
# . # . #
|
|
||||||
. # . # .`;
|
|
||||||
case IconNames.Diamond: return `
|
|
||||||
. . # . .
|
|
||||||
. # . # .
|
|
||||||
# . . . #
|
|
||||||
. # . # .
|
|
||||||
. . # . .`;
|
|
||||||
case IconNames.SmallDiamond: return `
|
|
||||||
. . . . .
|
|
||||||
. . # . .
|
|
||||||
. # . # .
|
|
||||||
. . # . .
|
|
||||||
. . . . .`;
|
|
||||||
case IconNames.Square: return `
|
|
||||||
# # # # #
|
|
||||||
# . . . #
|
|
||||||
# . . . #
|
|
||||||
# . . . #
|
|
||||||
# # # # #`;
|
|
||||||
case IconNames.SmallSquare: return `
|
|
||||||
. . . . .
|
|
||||||
. # # # .
|
|
||||||
. # . # .
|
|
||||||
. # # # .
|
|
||||||
. . . . .`;
|
|
||||||
// The following images were designed by Abbie Brooks.
|
|
||||||
case IconNames.TShirt: return `
|
|
||||||
# # . # #
|
|
||||||
# # # # #
|
|
||||||
. # # # .
|
|
||||||
. # # # .
|
|
||||||
. # # # .`;
|
|
||||||
case IconNames.Rollerskate: return `
|
|
||||||
. . . # #
|
|
||||||
. . . # #
|
|
||||||
# # # # #
|
|
||||||
# # # # #
|
|
||||||
. # . # .`;
|
|
||||||
case IconNames.Duck: return `
|
|
||||||
. # # . .
|
|
||||||
# # # . .
|
|
||||||
. # # # #
|
|
||||||
. # # # .
|
|
||||||
. .. . .`;
|
|
||||||
case IconNames.House: return `
|
|
||||||
. . # . .
|
|
||||||
. # # # .
|
|
||||||
# # # # #
|
|
||||||
. # # # .
|
|
||||||
. # . # .`;
|
|
||||||
case IconNames.Tortoise: return `
|
|
||||||
. . . . .
|
|
||||||
. # # # .
|
|
||||||
# # # # #
|
|
||||||
. # . # .
|
|
||||||
. . . . .`;
|
|
||||||
case IconNames.Butterfly: return `
|
|
||||||
# # . # #
|
|
||||||
# # # # #
|
|
||||||
. . # . .
|
|
||||||
# # # # #
|
|
||||||
# # . # #`;
|
|
||||||
case IconNames.StickFigure: return `
|
|
||||||
. . # . .
|
|
||||||
# # # # #
|
|
||||||
. . # . .
|
|
||||||
. # . # .
|
|
||||||
# . . . #`;
|
|
||||||
case IconNames.Ghost: return `
|
|
||||||
. # # # .
|
|
||||||
# . # . #
|
|
||||||
# # # # #
|
|
||||||
# # # # #
|
|
||||||
# . # . #`;
|
|
||||||
case IconNames.Sword: return `
|
|
||||||
. . # . .
|
|
||||||
. . # . .
|
|
||||||
. . # . .
|
|
||||||
. # # # .
|
|
||||||
. . # . .`;
|
|
||||||
case IconNames.Giraffe: return `
|
|
||||||
# # . . .
|
|
||||||
. # . . .
|
|
||||||
. # . . .
|
|
||||||
. # # # .
|
|
||||||
. # . # .`;
|
|
||||||
case IconNames.Skull: return `
|
|
||||||
. # # # .
|
|
||||||
# . # . #
|
|
||||||
# # # # #
|
|
||||||
. # # # .
|
|
||||||
. # # # .`;
|
|
||||||
case IconNames.Umbrella: return `
|
|
||||||
. # # # .
|
|
||||||
# # # # #
|
|
||||||
. . # . .
|
|
||||||
# . # . .
|
|
||||||
# # # . .`;
|
|
||||||
case IconNames.Snake: return `
|
|
||||||
# # . . .
|
|
||||||
# # . # #
|
|
||||||
. # . # .
|
|
||||||
. # # # .
|
|
||||||
. . . . .`;
|
|
||||||
// animals
|
|
||||||
case IconNames.Rabbit: return `
|
|
||||||
# . # . .
|
|
||||||
# . # . .
|
|
||||||
# # # # .
|
|
||||||
# # . # .
|
|
||||||
# # # # .`;
|
|
||||||
case IconNames.Cow: return `
|
|
||||||
# . . . #
|
|
||||||
# . . . #
|
|
||||||
# # # # #
|
|
||||||
. # # # .
|
|
||||||
. . # . .`;
|
|
||||||
// musical notes
|
|
||||||
case IconNames.QuarterNote: return `
|
|
||||||
. . # . .
|
|
||||||
. . # . .
|
|
||||||
. . # . .
|
|
||||||
# # # . .
|
|
||||||
# # # . .`;
|
|
||||||
case IconNames.EigthNote: return `
|
|
||||||
. . # . .
|
|
||||||
. . # # .
|
|
||||||
. . # . #
|
|
||||||
# # # . .
|
|
||||||
# # # . .`;
|
|
||||||
// other icons
|
|
||||||
case IconNames.Pitchfork: return `
|
|
||||||
# . # . #
|
|
||||||
# . # . #
|
|
||||||
# # # # #
|
|
||||||
. . # . .
|
|
||||||
. . # . .`;
|
|
||||||
case IconNames.Pacman: return `
|
|
||||||
. # # # #
|
|
||||||
# # # # .
|
|
||||||
# # # . .
|
|
||||||
# # # # .
|
|
||||||
. # # # #`;
|
|
||||||
case IconNames.Target: return `
|
|
||||||
. . # . .
|
|
||||||
. # # # .
|
|
||||||
# # . # #
|
|
||||||
. # # # .
|
|
||||||
. . # . .`;
|
|
||||||
default: return `
|
|
||||||
. . . . .
|
|
||||||
. . . . .
|
|
||||||
. . . . .
|
|
||||||
. . . . .
|
|
||||||
. . . . .
|
|
||||||
`;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//% weight=50 blockGap=8
|
//% weight=50 blockGap=8
|
||||||
|
//% help=images/icon-image
|
||||||
|
//% blockId=builtin_image block="icon image %i"
|
||||||
|
//% i.fieldEditor="gridpicker"
|
||||||
|
//% i.fieldOptions.width="400" i.fieldOptions.columns="5"
|
||||||
|
//% i.fieldOptions.itemColour="black" i.fieldOptions.tooltips="true"
|
||||||
|
export function iconImage(i: IconNames): Image {
|
||||||
|
switch (i) {
|
||||||
|
case IconNames.Heart: return images.createImage(`
|
||||||
|
. # . # .
|
||||||
|
# # # # #
|
||||||
|
# # # # #
|
||||||
|
. # # # .
|
||||||
|
. . # . .`);
|
||||||
|
|
||||||
|
case IconNames.SmallHeart: return images.createImage(`
|
||||||
|
. . . . .
|
||||||
|
. # . # .
|
||||||
|
. # # # .
|
||||||
|
. . # . .
|
||||||
|
. . . . .`);
|
||||||
|
//faces
|
||||||
|
case IconNames.Happy: return images.createImage(`
|
||||||
|
. . . . .
|
||||||
|
. # . # .
|
||||||
|
. . . . .
|
||||||
|
# . . . #
|
||||||
|
. # # # .`);
|
||||||
|
case IconNames.Sad: return images.createImage(`
|
||||||
|
. . . . .
|
||||||
|
. # . # .
|
||||||
|
. . . . .
|
||||||
|
. # # # .
|
||||||
|
# . . . #`);
|
||||||
|
case IconNames.Confused: return images.createImage(`
|
||||||
|
. . . . .
|
||||||
|
. # . # .
|
||||||
|
. . . . .
|
||||||
|
. # . # .
|
||||||
|
# . # . #`);
|
||||||
|
case IconNames.Angry: return images.createImage(`
|
||||||
|
# . . . #
|
||||||
|
. # . # .
|
||||||
|
. . . . .
|
||||||
|
# # # # #
|
||||||
|
# . # . #`);
|
||||||
|
case IconNames.Asleep: return images.createImage(`
|
||||||
|
. . . . .
|
||||||
|
# # . # #
|
||||||
|
. . . . .
|
||||||
|
. # # # .
|
||||||
|
. . . . .`);
|
||||||
|
case IconNames.Surprised: return images.createImage(`
|
||||||
|
. # . # .
|
||||||
|
. . . . .
|
||||||
|
. . # . .
|
||||||
|
. # . # .
|
||||||
|
. . # . .`);
|
||||||
|
case IconNames.Silly: return images.createImage(`
|
||||||
|
# . . . #
|
||||||
|
. . . . .
|
||||||
|
# # # # #
|
||||||
|
. . . # #
|
||||||
|
. . . # #`);
|
||||||
|
case IconNames.Fabulous: return images.createImage(`
|
||||||
|
# # # # #
|
||||||
|
# # . # #
|
||||||
|
. . . . .
|
||||||
|
. # . # .
|
||||||
|
. # # # .`);
|
||||||
|
case IconNames.Meh: return images.createImage(`
|
||||||
|
# # . # #
|
||||||
|
. . . . .
|
||||||
|
. . . # .
|
||||||
|
. . # . .
|
||||||
|
. # . . .`);
|
||||||
|
case IconNames.Yes: return images.createImage(`
|
||||||
|
. . . . .
|
||||||
|
. . . . #
|
||||||
|
. . . # .
|
||||||
|
# . # . .
|
||||||
|
. # . . .`);
|
||||||
|
case IconNames.No: return images.createImage(`
|
||||||
|
# . . . #
|
||||||
|
. # . # .
|
||||||
|
. . # . .
|
||||||
|
. # . # .
|
||||||
|
# . . . #`);
|
||||||
|
case IconNames.Triangle: return images.createImage(`
|
||||||
|
. . . . .
|
||||||
|
. . # . .
|
||||||
|
. # . # .
|
||||||
|
# # # # #
|
||||||
|
. . . . .`);
|
||||||
|
case IconNames.LeftTriangle: return images.createImage(`
|
||||||
|
# . . . .
|
||||||
|
# # . . .
|
||||||
|
# . # . .
|
||||||
|
# . . # .
|
||||||
|
# # # # #`);
|
||||||
|
case IconNames.Chessboard: return images.createImage(`
|
||||||
|
. # . # .
|
||||||
|
# . # . #
|
||||||
|
. # . # .
|
||||||
|
# . # . #
|
||||||
|
. # . # .`);
|
||||||
|
case IconNames.Diamond: return images.createImage(`
|
||||||
|
. . # . .
|
||||||
|
. # . # .
|
||||||
|
# . . . #
|
||||||
|
. # . # .
|
||||||
|
. . # . .`);
|
||||||
|
case IconNames.SmallDiamond: return images.createImage(`
|
||||||
|
. . . . .
|
||||||
|
. . # . .
|
||||||
|
. # . # .
|
||||||
|
. . # . .
|
||||||
|
. . . . .`);
|
||||||
|
case IconNames.Square: return images.createImage(`
|
||||||
|
# # # # #
|
||||||
|
# . . . #
|
||||||
|
# . . . #
|
||||||
|
# . . . #
|
||||||
|
# # # # #`);
|
||||||
|
case IconNames.SmallSquare: return images.createImage(`
|
||||||
|
. . . . .
|
||||||
|
. # # # .
|
||||||
|
. # . # .
|
||||||
|
. # # # .
|
||||||
|
. . . . .`);
|
||||||
|
|
||||||
|
case IconNames.Scissors: return images.createImage(`
|
||||||
|
# # . . #
|
||||||
|
# # . # .
|
||||||
|
. . # . .
|
||||||
|
# # . # .
|
||||||
|
# # . . #`);
|
||||||
|
// The following images were designed by Abbie Brooks.
|
||||||
|
case IconNames.TShirt: return images.createImage(`
|
||||||
|
# # . # #
|
||||||
|
# # # # #
|
||||||
|
. # # # .
|
||||||
|
. # # # .
|
||||||
|
. # # # .`);
|
||||||
|
case IconNames.Rollerskate: return images.createImage(`
|
||||||
|
. . . # #
|
||||||
|
. . . # #
|
||||||
|
# # # # #
|
||||||
|
# # # # #
|
||||||
|
. # . # .`);
|
||||||
|
case IconNames.Duck: return images.createImage(`
|
||||||
|
. # # . .
|
||||||
|
# # # . .
|
||||||
|
. # # # #
|
||||||
|
. # # # .
|
||||||
|
. . . . .`);
|
||||||
|
case IconNames.House: return images.createImage(`
|
||||||
|
. . # . .
|
||||||
|
. # # # .
|
||||||
|
# # # # #
|
||||||
|
. # # # .
|
||||||
|
. # . # .`);
|
||||||
|
case IconNames.Tortoise: return images.createImage(`
|
||||||
|
. . . . .
|
||||||
|
. # # # .
|
||||||
|
# # # # #
|
||||||
|
. # . # .
|
||||||
|
. . . . .`);
|
||||||
|
case IconNames.Butterfly: return images.createImage(`
|
||||||
|
# # . # #
|
||||||
|
# # # # #
|
||||||
|
. . # . .
|
||||||
|
# # # # #
|
||||||
|
# # . # #`);
|
||||||
|
case IconNames.StickFigure: return images.createImage(`
|
||||||
|
. . # . .
|
||||||
|
# # # # #
|
||||||
|
. . # . .
|
||||||
|
. # . # .
|
||||||
|
# . . . #`);
|
||||||
|
case IconNames.Ghost: return images.createImage(`
|
||||||
|
. # # # .
|
||||||
|
# . # . #
|
||||||
|
# # # # #
|
||||||
|
# # # # #
|
||||||
|
# . # . #`);
|
||||||
|
case IconNames.Sword: return images.createImage(`
|
||||||
|
. . # . .
|
||||||
|
. . # . .
|
||||||
|
. . # . .
|
||||||
|
. # # # .
|
||||||
|
. . # . .`);
|
||||||
|
case IconNames.Giraffe: return images.createImage(`
|
||||||
|
# # . . .
|
||||||
|
. # . . .
|
||||||
|
. # . . .
|
||||||
|
. # # # .
|
||||||
|
. # . # .`);
|
||||||
|
case IconNames.Skull: return images.createImage(`
|
||||||
|
. # # # .
|
||||||
|
# . # . #
|
||||||
|
# # # # #
|
||||||
|
. # # # .
|
||||||
|
. # # # .`);
|
||||||
|
case IconNames.Umbrella: return images.createImage(`
|
||||||
|
. # # # .
|
||||||
|
# # # # #
|
||||||
|
. . # . .
|
||||||
|
# . # . .
|
||||||
|
# # # . .`);
|
||||||
|
case IconNames.Snake: return images.createImage(`
|
||||||
|
# # . . .
|
||||||
|
# # . # #
|
||||||
|
. # . # .
|
||||||
|
. # # # .
|
||||||
|
. . . . .`);
|
||||||
|
// animals
|
||||||
|
case IconNames.Rabbit: return images.createImage(`
|
||||||
|
# . # . .
|
||||||
|
# . # . .
|
||||||
|
# # # # .
|
||||||
|
# # . # .
|
||||||
|
# # # # .`);
|
||||||
|
case IconNames.Cow: return images.createImage(`
|
||||||
|
# . . . #
|
||||||
|
# . . . #
|
||||||
|
# # # # #
|
||||||
|
. # # # .
|
||||||
|
. . # . .`);
|
||||||
|
// musical notes
|
||||||
|
case IconNames.QuarterNote: return images.createImage(`
|
||||||
|
. . # . .
|
||||||
|
. . # . .
|
||||||
|
. . # . .
|
||||||
|
# # # . .
|
||||||
|
# # # . .`);
|
||||||
|
case IconNames.EigthNote: return images.createImage(`
|
||||||
|
. . # . .
|
||||||
|
. . # # .
|
||||||
|
. . # . #
|
||||||
|
# # # . .
|
||||||
|
# # # . .`);
|
||||||
|
// other icons
|
||||||
|
case IconNames.Pitchfork: return images.createImage(`
|
||||||
|
# . # . #
|
||||||
|
# . # . #
|
||||||
|
# # # # #
|
||||||
|
. . # . .
|
||||||
|
. . # . .`);
|
||||||
|
case IconNames.Target: return images.createImage(`
|
||||||
|
. . # . .
|
||||||
|
. # # # .
|
||||||
|
# # . # #
|
||||||
|
. # # # .
|
||||||
|
. . # . .`);
|
||||||
|
default: return images.createImage(`
|
||||||
|
. . . . .
|
||||||
|
. . . . .
|
||||||
|
. . . . .
|
||||||
|
. . . . .
|
||||||
|
. . . . .
|
||||||
|
`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//% weight=50 blockGap=8
|
||||||
|
//% help=images/arrow-number
|
||||||
//% blockId=device_arrow block="%arrow"
|
//% blockId=device_arrow block="%arrow"
|
||||||
//% shim=TD_ID
|
//% shim=TD_ID
|
||||||
export function arrowNumber(arrow: ArrowNames): number {
|
export function arrowNumber(arrow: ArrowNames): number {
|
||||||
return arrow;
|
return arrow;
|
||||||
}
|
}
|
||||||
|
|
||||||
//% weight=50 blockGap=8
|
|
||||||
//% blockId=builtin_arrow_image block="arrow image %i=device_arrow"
|
|
||||||
export function arrowImage(i: ArrowNames): Image {
|
|
||||||
let res = images.createImage(`
|
|
||||||
. . . . .
|
|
||||||
. . . . .
|
|
||||||
. . . . .
|
|
||||||
. . . . .
|
|
||||||
. . . . .
|
|
||||||
`)
|
|
||||||
return set(res, getArrow(i));
|
|
||||||
}
|
|
||||||
|
|
||||||
//% weight=50 blockGap=8
|
|
||||||
//% blockId=builtin_image block="icon image %i"
|
|
||||||
export function iconImage(i: IconNames): Image {
|
|
||||||
let res = images.createImage(`
|
|
||||||
. . . . .
|
|
||||||
. . . . .
|
|
||||||
. . . . .
|
|
||||||
. . . . .
|
|
||||||
. . . . .
|
|
||||||
`)
|
|
||||||
return set(res, getIcon(i));
|
|
||||||
}
|
|
||||||
|
|
||||||
function set(res: Image, s: string) {
|
|
||||||
let j = 0;
|
|
||||||
for (let x of s) {
|
|
||||||
if (x == "." || x == "#") {
|
|
||||||
res.setPixel(j % 5, j / 5, x == "#")
|
|
||||||
j++
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return res
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
BIN
sim/public/blocks/iconnames/angry.png
Normal file
After Width: | Height: | Size: 2.6 KiB |
BIN
sim/public/blocks/iconnames/asleep.png
Normal file
After Width: | Height: | Size: 2.5 KiB |
BIN
sim/public/blocks/iconnames/butterfly.png
Normal file
After Width: | Height: | Size: 2.8 KiB |
BIN
sim/public/blocks/iconnames/chessboard.png
Normal file
After Width: | Height: | Size: 2.7 KiB |
BIN
sim/public/blocks/iconnames/confused.png
Normal file
After Width: | Height: | Size: 2.5 KiB |
BIN
sim/public/blocks/iconnames/cow.png
Normal file
After Width: | Height: | Size: 2.6 KiB |
BIN
sim/public/blocks/iconnames/diamond.png
Normal file
After Width: | Height: | Size: 2.7 KiB |
BIN
sim/public/blocks/iconnames/duck.png
Normal file
After Width: | Height: | Size: 2.6 KiB |
BIN
sim/public/blocks/iconnames/eigthnote.png
Normal file
After Width: | Height: | Size: 2.7 KiB |
BIN
sim/public/blocks/iconnames/fabulous.png
Normal file
After Width: | Height: | Size: 2.6 KiB |
BIN
sim/public/blocks/iconnames/ghost.png
Normal file
After Width: | Height: | Size: 2.7 KiB |
BIN
sim/public/blocks/iconnames/giraffe.png
Normal file
After Width: | Height: | Size: 2.7 KiB |
BIN
sim/public/blocks/iconnames/happy.png
Normal file
After Width: | Height: | Size: 2.5 KiB |
BIN
sim/public/blocks/iconnames/heart.png
Normal file
After Width: | Height: | Size: 2.7 KiB |
BIN
sim/public/blocks/iconnames/house.png
Normal file
After Width: | Height: | Size: 2.7 KiB |
BIN
sim/public/blocks/iconnames/lefttriangle.png
Normal file
After Width: | Height: | Size: 2.7 KiB |
BIN
sim/public/blocks/iconnames/meh.png
Normal file
After Width: | Height: | Size: 2.7 KiB |
BIN
sim/public/blocks/iconnames/no.png
Normal file
After Width: | Height: | Size: 2.6 KiB |
BIN
sim/public/blocks/iconnames/pitchfork.png
Normal file
After Width: | Height: | Size: 2.8 KiB |
BIN
sim/public/blocks/iconnames/quarternote.png
Normal file
After Width: | Height: | Size: 2.7 KiB |
BIN
sim/public/blocks/iconnames/rabbit.png
Normal file
After Width: | Height: | Size: 2.7 KiB |
BIN
sim/public/blocks/iconnames/rollerskate.png
Normal file
After Width: | Height: | Size: 2.6 KiB |
BIN
sim/public/blocks/iconnames/sad.png
Normal file
After Width: | Height: | Size: 2.5 KiB |
BIN
sim/public/blocks/iconnames/scissors.png
Normal file
After Width: | Height: | Size: 8.0 KiB |
BIN
sim/public/blocks/iconnames/silly.png
Normal file
After Width: | Height: | Size: 2.5 KiB |
BIN
sim/public/blocks/iconnames/skull.png
Normal file
After Width: | Height: | Size: 2.7 KiB |
BIN
sim/public/blocks/iconnames/smalldiamond.png
Normal file
After Width: | Height: | Size: 2.5 KiB |
BIN
sim/public/blocks/iconnames/smallheart.png
Normal file
After Width: | Height: | Size: 2.5 KiB |
BIN
sim/public/blocks/iconnames/smallsquare.png
Normal file
After Width: | Height: | Size: 2.5 KiB |
BIN
sim/public/blocks/iconnames/snake.png
Normal file
After Width: | Height: | Size: 2.6 KiB |
BIN
sim/public/blocks/iconnames/square.png
Normal file
After Width: | Height: | Size: 2.5 KiB |
BIN
sim/public/blocks/iconnames/stickfigure.png
Normal file
After Width: | Height: | Size: 2.7 KiB |
BIN
sim/public/blocks/iconnames/surprised.png
Normal file
After Width: | Height: | Size: 2.6 KiB |
BIN
sim/public/blocks/iconnames/sword.png
Normal file
After Width: | Height: | Size: 2.7 KiB |
BIN
sim/public/blocks/iconnames/target.png
Normal file
After Width: | Height: | Size: 2.7 KiB |
BIN
sim/public/blocks/iconnames/tortoise.png
Normal file
After Width: | Height: | Size: 2.5 KiB |
BIN
sim/public/blocks/iconnames/triangle.png
Normal file
After Width: | Height: | Size: 2.6 KiB |
BIN
sim/public/blocks/iconnames/tshirt.png
Normal file
After Width: | Height: | Size: 2.7 KiB |
BIN
sim/public/blocks/iconnames/umbrella.png
Normal file
After Width: | Height: | Size: 2.8 KiB |
BIN
sim/public/blocks/iconnames/yes.png
Normal file
After Width: | Height: | Size: 2.5 KiB |