Skip to content

Commit

Permalink
Screen clear lines block (#1039)
Browse files Browse the repository at this point in the history
* add-clear-lines-block

* Update targetoverrides.ts

* Update targetoverrides.ts

* Update targetoverrides.ts
  • Loading branch information
THEb0nny authored Nov 2, 2023
1 parent cd3ea47 commit ac41b8a
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions libs/screen/targetoverrides.ts
Original file line number Diff line number Diff line change
Expand Up @@ -311,12 +311,29 @@ namespace brick {
return image;
}

/**
* Clear on the screen at a specific lines (1..12).
* @param lines list of lines to clear (starting at 1 and ends with 12)
*/
//% blockId=clearLines block="clear lines $lines"
//% weight=94 group="Screen" inlineInputMode="inline" blockGap=8
export function clearLines(lines: number[]) {
if (screenMode != ScreenMode.ShowLines) {
screenMode = ScreenMode.ShowLines;
screen.fill(0);
}

for (let i = 0; i < lines.length; i++) {
clearLine(lines[i]);
}
}

/**
* Clear on the screen at a specific line.
* @param line the line number to clear at (starting at 1), eg: 1
*/
//% blockId=clearLine block="clear line $line"
//% weight=94 group="Screen" inlineInputMode="inline" blockGap=8
//% weight=93 group="Screen" inlineInputMode="inline" blockGap=8
//% line.min=1 line.max=12
export function clearLine(line: number) {
if (screenMode != ScreenMode.ShowLines) {
Expand All @@ -337,7 +354,7 @@ namespace brick {
* Clear the screen
*/
//% blockId=screen_clear_screen block="clear screen"
//% weight=93 group="Screen"
//% weight=92 group="Screen"
//% help=brick/clear-screen weight=1
export function clearScreen() {
screen.fill(0)
Expand Down

0 comments on commit ac41b8a

Please sign in to comment.