more missing simulator functions

This commit is contained in:
Peli de Halleux 2016-04-18 09:47:27 -07:00
parent 5e23bc96ca
commit 6cbc6a53b2
2 changed files with 30 additions and 1 deletions

View File

@ -564,6 +564,34 @@ namespace pxsim.ImageMethods {
runtime.queueDisplayUpdate()
}
export function height(leds: Image) : number {
if (!leds) panic(PanicCode.MICROBIT_NULL_DEREFERENCE);
return Image.height;
}
export function width(leds: Image) : number {
if (!leds) panic(PanicCode.MICROBIT_NULL_DEREFERENCE);
return leds.width;
}
export function plotFrame(leds: Image, frame: number) {
ImageMethods.plotImage(leds, frame * Image.height);
}
export function showFrame(leds: Image, frame: number) {
ImageMethods.showImage(leds, frame * Image.height);
}
export function pixel(leds: Image, x: number, y: number) : number {
if (!leds) panic(PanicCode.MICROBIT_NULL_DEREFERENCE);
return leds.get(x,y);
}
export function setPixel(leds: Image, x: number, y: number, v:number) {
if (!leds) panic(PanicCode.MICROBIT_NULL_DEREFERENCE);
leds.set(x,y,v);
}
export function clear(leds: Image) {
if (!leds) panic(PanicCode.MICROBIT_NULL_DEREFERENCE);

View File

@ -611,6 +611,7 @@ namespace pxsim {
}
export class Image {
public static height: number = 5;
public width: number;
public data: number[];
constructor(width: number, data: number[]) {