2017-01-31 01:51:40 +01:00
|
|
|
/*
|
|
|
|
The MIT License (MIT)
|
|
|
|
|
|
|
|
Copyright (c) 2013-2016 The MicroPython-on-micro:bit Developers, as listed
|
|
|
|
in the accompanying AUTHORS file
|
|
|
|
|
|
|
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
of this software and associated documentation files (the "Software"), to deal
|
|
|
|
in the Software without restriction, including without limitation the rights
|
|
|
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
copies of the Software, and to permit persons to whom the Software is
|
|
|
|
furnished to do so, subject to the following conditions:
|
|
|
|
|
|
|
|
The above copyright notice and this permission notice shall be included in
|
|
|
|
all copies or substantial portions of the Software.
|
|
|
|
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
|
THE SOFTWARE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
// Images from file microbitconstimage.cpp https://github.com/bbcmicrobit/micropython
|
|
|
|
|
2017-01-31 01:42:48 +01:00
|
|
|
enum IconNames {
|
2017-02-01 23:08:23 +01:00
|
|
|
//% block="heart"
|
2017-01-31 00:03:50 +01:00
|
|
|
Heart = 0,
|
2017-02-01 00:54:23 +01:00
|
|
|
//% block="small heart"
|
2017-01-31 00:03:50 +01:00
|
|
|
SmallHeart,
|
2017-02-01 00:54:23 +01:00
|
|
|
//% block="yes"
|
2017-01-31 00:33:33 +01:00
|
|
|
Yes,
|
2017-02-01 00:54:23 +01:00
|
|
|
//% block="no"
|
2017-01-31 00:33:33 +01:00
|
|
|
No,
|
2017-02-01 00:54:23 +01:00
|
|
|
//% block="happy"
|
2017-01-31 00:03:50 +01:00
|
|
|
Happy,
|
2017-02-01 00:54:23 +01:00
|
|
|
//% block="sad"
|
2017-01-31 00:03:50 +01:00
|
|
|
Sad,
|
2017-02-01 00:54:23 +01:00
|
|
|
//% block="confused"
|
2017-01-31 00:03:50 +01:00
|
|
|
Confused,
|
2017-02-01 00:54:23 +01:00
|
|
|
//% block="angry"
|
2017-01-31 00:03:50 +01:00
|
|
|
Angry,
|
2017-02-01 00:54:23 +01:00
|
|
|
//% block="asleep"
|
2017-01-31 00:03:50 +01:00
|
|
|
Asleep,
|
2017-02-01 00:54:23 +01:00
|
|
|
//% block="surprised"
|
2017-01-31 00:03:50 +01:00
|
|
|
Surprised,
|
2017-02-01 00:54:23 +01:00
|
|
|
//% block="silly"
|
2017-01-31 00:03:50 +01:00
|
|
|
Silly,
|
2017-02-01 00:54:23 +01:00
|
|
|
//% block="fabulous"
|
2017-01-31 00:03:50 +01:00
|
|
|
Fabulous,
|
2017-02-01 00:54:23 +01:00
|
|
|
//% block="meh"
|
2017-01-31 00:03:50 +01:00
|
|
|
Meh,
|
2017-02-01 00:54:23 +01:00
|
|
|
//% block="t-shirt"
|
2017-01-31 00:03:50 +01:00
|
|
|
TShirt,
|
2017-02-01 00:54:23 +01:00
|
|
|
//% block="roller skate"
|
2017-01-31 00:03:50 +01:00
|
|
|
Rollerskate,
|
2017-02-01 00:54:23 +01:00
|
|
|
//% block="duck"
|
2017-01-31 00:03:50 +01:00
|
|
|
Duck,
|
2017-02-01 00:54:23 +01:00
|
|
|
//% block="house"
|
2017-01-31 00:03:50 +01:00
|
|
|
House,
|
2017-02-01 00:54:23 +01:00
|
|
|
//% block="tortoise"
|
2017-01-31 00:03:50 +01:00
|
|
|
Tortoise,
|
2017-02-01 00:54:23 +01:00
|
|
|
//% block="butterfly"
|
2017-01-31 00:03:50 +01:00
|
|
|
Butterfly,
|
2017-02-01 00:54:23 +01:00
|
|
|
//% block="stick figure"
|
2017-01-31 00:03:50 +01:00
|
|
|
StickFigure,
|
2017-02-01 00:54:23 +01:00
|
|
|
//% block="ghost"
|
2017-01-31 00:03:50 +01:00
|
|
|
Ghost,
|
2017-02-01 00:54:23 +01:00
|
|
|
//% block="sword"
|
2017-01-31 00:03:50 +01:00
|
|
|
Sword,
|
2017-02-01 00:54:23 +01:00
|
|
|
//% block="giraffe"
|
2017-01-31 00:03:50 +01:00
|
|
|
Giraffe,
|
2017-02-01 00:54:23 +01:00
|
|
|
//% block="skull"
|
2017-01-31 00:03:50 +01:00
|
|
|
Skull,
|
2017-02-01 00:54:23 +01:00
|
|
|
//% block="umbrella"
|
2017-01-31 00:03:50 +01:00
|
|
|
Umbrella,
|
2017-02-01 00:54:23 +01:00
|
|
|
//% block="snake"
|
2017-01-31 00:03:50 +01:00
|
|
|
Snake,
|
2017-02-01 00:54:23 +01:00
|
|
|
//% block="rabbit"
|
2017-01-31 00:03:50 +01:00
|
|
|
Rabbit,
|
2017-02-01 00:54:23 +01:00
|
|
|
//% block="cow"
|
2017-01-31 00:03:50 +01:00
|
|
|
Cow,
|
2017-02-01 00:54:23 +01:00
|
|
|
//% block="quarter note"
|
2017-01-31 00:03:50 +01:00
|
|
|
QuarterNote,
|
2017-02-01 00:54:23 +01:00
|
|
|
//% block="eigth note"
|
2017-01-31 00:03:50 +01:00
|
|
|
EigthNote,
|
2017-02-01 00:54:23 +01:00
|
|
|
//% block="pitchfork"
|
2017-01-31 00:03:50 +01:00
|
|
|
Pitchfork,
|
2017-02-01 00:54:23 +01:00
|
|
|
//% block="pac man"
|
2017-01-31 00:03:50 +01:00
|
|
|
Pacman,
|
2017-02-01 00:54:23 +01:00
|
|
|
//% block="target"
|
2017-01-31 00:33:33 +01:00
|
|
|
Target,
|
2017-02-01 00:54:23 +01:00
|
|
|
//% block="triangle"
|
2017-01-31 00:33:33 +01:00
|
|
|
Triangle,
|
2017-02-01 00:54:23 +01:00
|
|
|
//% block="left triangle"
|
2017-01-31 00:33:33 +01:00
|
|
|
LeftTriangle,
|
2017-02-01 00:54:23 +01:00
|
|
|
//% block="chess board"
|
2017-01-31 00:33:33 +01:00
|
|
|
Chessboard,
|
2017-02-01 00:54:23 +01:00
|
|
|
//% block="diamond"
|
2017-01-31 00:33:33 +01:00
|
|
|
Diamond,
|
2017-02-01 00:54:23 +01:00
|
|
|
//% block="small diamond"
|
2017-01-31 00:33:33 +01:00
|
|
|
SmallDiamond,
|
2017-02-01 00:54:23 +01:00
|
|
|
//% block="square"
|
2017-01-31 00:33:33 +01:00
|
|
|
Square,
|
2017-02-01 00:54:23 +01:00
|
|
|
//% block="small square"
|
2017-02-11 01:33:52 +01:00
|
|
|
SmallSquare,
|
2017-01-31 00:03:50 +01:00
|
|
|
}
|
|
|
|
|
2017-02-01 23:08:23 +01:00
|
|
|
enum ArrowNames {
|
|
|
|
//% blockIdentity=images.arrowNumber
|
|
|
|
North = 0,
|
|
|
|
//% blockIdentity=images.arrowNumber
|
|
|
|
NorthEast,
|
|
|
|
//% blockIdentity=images.arrowNumber
|
|
|
|
East,
|
|
|
|
//% blockIdentity=images.arrowNumber
|
|
|
|
SouthEast,
|
|
|
|
//% blockIdentity=images.arrowNumber
|
|
|
|
South,
|
|
|
|
//% blockIdentity=images.arrowNumber
|
|
|
|
SouthWest,
|
|
|
|
//% blockIdentity=images.arrowNumber
|
|
|
|
West,
|
|
|
|
//% blockIdentity=images.arrowNumber
|
|
|
|
NorthWest,
|
|
|
|
}
|
|
|
|
|
2017-01-31 01:42:48 +01:00
|
|
|
namespace basic {
|
|
|
|
|
2017-01-31 02:05:06 +01:00
|
|
|
/**
|
|
|
|
* Draws the selected icon on the LED screen
|
|
|
|
*/
|
|
|
|
//% weight=90 blockGap=8
|
|
|
|
//% blockId=basic_show_icon
|
|
|
|
//% block="show icon %i" icon="\uf00a"
|
|
|
|
//% parts="ledmatrix"
|
|
|
|
export function showIcon(icon: IconNames) {
|
|
|
|
let res = images.iconImage(icon)
|
|
|
|
res.showImage(0)
|
|
|
|
}
|
|
|
|
|
2017-02-01 00:54:23 +01:00
|
|
|
//% weight=50 blockGap=8
|
|
|
|
//% blockId=basic_show_arrow
|
|
|
|
//% block="show arrow %i=device_arrow"
|
|
|
|
//% parts="ledmatrix"
|
|
|
|
//% advanced=true
|
2017-01-31 01:42:48 +01:00
|
|
|
export function showArrow(i: number) {
|
|
|
|
let res = images.arrowImage(i)
|
|
|
|
res.showImage(0)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-01-31 02:05:06 +01:00
|
|
|
|
2017-01-31 01:42:48 +01:00
|
|
|
namespace images {
|
|
|
|
|
2017-02-11 01:33:52 +01:00
|
|
|
function getArrow(i : ArrowNames): string {
|
|
|
|
switch(i) {
|
|
|
|
// compass directions
|
|
|
|
case ArrowNames.North: return `
|
|
|
|
. . # . .
|
|
|
|
. # # # .
|
|
|
|
# . # . #
|
|
|
|
. . # . .
|
|
|
|
. . # . .`;
|
|
|
|
case ArrowNames.NorthEast: return `
|
|
|
|
. . # # #
|
|
|
|
. . . # #
|
|
|
|
. . # . #
|
|
|
|
. # . . .
|
|
|
|
# . . . .`;
|
|
|
|
case ArrowNames.East: return `
|
|
|
|
. . # . .
|
|
|
|
. . . # .
|
|
|
|
# # # # #
|
|
|
|
. . . # .
|
|
|
|
. . # . .`;
|
|
|
|
case ArrowNames.SouthEast: return `
|
|
|
|
# . . . .
|
|
|
|
. # . . .
|
|
|
|
. . # . #
|
|
|
|
. . . # #
|
|
|
|
. . # # #`;
|
|
|
|
case ArrowNames.South: return `
|
|
|
|
. . # . .
|
|
|
|
. . # . .
|
|
|
|
# . # . #
|
|
|
|
. # # # .
|
|
|
|
. . # . .`;
|
|
|
|
case ArrowNames.SouthWest: return `
|
|
|
|
. . . . #
|
|
|
|
. . . # .
|
|
|
|
# . # . .
|
|
|
|
# # . . .
|
|
|
|
# # # . .`;
|
|
|
|
case ArrowNames.West: return `
|
|
|
|
. . # . .
|
|
|
|
. # . . .
|
|
|
|
# # # # #
|
|
|
|
. # . . .
|
|
|
|
. . # . .`;
|
|
|
|
case ArrowNames.NorthWest: return `
|
|
|
|
# # # . .
|
|
|
|
# # . . .
|
|
|
|
# . # . .
|
|
|
|
. . . # .
|
|
|
|
. . . . #`;
|
|
|
|
default: return `
|
|
|
|
. . . . .
|
|
|
|
. . . . .
|
|
|
|
. . . . .
|
|
|
|
. . . . .
|
|
|
|
. . . . .
|
|
|
|
`;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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 `
|
|
|
|
. . . . .
|
|
|
|
. . . . .
|
|
|
|
. . . . .
|
|
|
|
. . . . .
|
|
|
|
. . . . .
|
|
|
|
`;
|
|
|
|
}
|
|
|
|
}
|
2017-01-31 00:03:50 +01:00
|
|
|
|
2017-02-01 00:54:23 +01:00
|
|
|
//% weight=50 blockGap=8
|
2017-01-31 00:03:50 +01:00
|
|
|
//% blockId=device_arrow block="%arrow"
|
|
|
|
//% shim=TD_ID
|
|
|
|
export function arrowNumber(arrow: ArrowNames): number {
|
|
|
|
return arrow;
|
|
|
|
}
|
|
|
|
|
2017-02-01 00:54:23 +01:00
|
|
|
//% weight=50 blockGap=8
|
2017-01-31 00:03:50 +01:00
|
|
|
//% blockId=builtin_arrow_image block="arrow image %i=device_arrow"
|
|
|
|
export function arrowImage(i: ArrowNames): Image {
|
|
|
|
let res = images.createImage(`
|
|
|
|
. . . . .
|
|
|
|
. . . . .
|
|
|
|
. . . . .
|
|
|
|
. . . . .
|
|
|
|
. . . . .
|
|
|
|
`)
|
2017-02-11 01:33:52 +01:00
|
|
|
return set(res, getArrow(i));
|
2017-01-31 00:03:50 +01:00
|
|
|
}
|
|
|
|
|
2017-02-01 00:54:23 +01:00
|
|
|
//% weight=50 blockGap=8
|
2017-01-31 23:56:56 +01:00
|
|
|
//% blockId=builtin_image block="icon image %i"
|
2017-01-31 00:03:50 +01:00
|
|
|
export function iconImage(i: IconNames): Image {
|
|
|
|
let res = images.createImage(`
|
|
|
|
. . . . .
|
|
|
|
. . . . .
|
2017-02-01 00:54:23 +01:00
|
|
|
. . . . .
|
2017-01-31 00:03:50 +01:00
|
|
|
. . . . .
|
|
|
|
. . . . .
|
|
|
|
`)
|
2017-02-11 01:33:52 +01:00
|
|
|
return set(res, getIcon(i));
|
2017-01-31 00:03:50 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
}
|