Compare commits

...

9 Commits

Author SHA1 Message Date
39b30c8ae1 0.3.46 2016-08-25 16:02:54 -07:00
1c5d6316cc Bump pxt-core to 0.3.51 2016-08-25 16:02:53 -07:00
6d4d681898 Link to pxt package docs 2016-08-25 17:44:53 +02:00
7053fd1490 Ref-counting fix 2016-08-25 15:45:43 +02:00
e7a49acac0 0.3.45 2016-08-24 15:03:29 +03:00
d76cfb6e2e Bump pxt-core to 0.3.49 2016-08-24 15:03:28 +03:00
538f08052d Make Image ref-counted; fixes #171 2016-08-24 15:02:55 +03:00
b6fed71c58 0.3.44 2016-08-24 14:38:50 +03:00
6c86f98b66 Bump pxt-core to 0.3.48 2016-08-24 14:38:50 +03:00
3 changed files with 18 additions and 7 deletions

View File

@ -23,7 +23,7 @@ To remove a package, click on the garbage button in the file list next to the pa
## Publishing packages
Packages can be published from the pxt command line. We are still sorting out the details.
Packages can be published from the pxt command line. Check out [the docs](https://www.pxt.io/packages).
## Localizing packages

View File

@ -1,6 +1,6 @@
{
"name": "pxt-microbit",
"version": "0.3.43",
"version": "0.3.46",
"description": "micro:bit target for PXT",
"keywords": [
"JavaScript",
@ -29,6 +29,6 @@
"typescript": "^1.8.7"
},
"dependencies": {
"pxt-core": "0.3.47"
"pxt-core": "0.3.51"
}
}

View File

@ -470,7 +470,7 @@ namespace pxsim {
radio: RadioBus;
// display
image = createImage(5);
image = createInternalImage(5);
brigthness = 255;
displayMode = DisplayMode.bw;
font: Image = createFont();
@ -608,14 +608,19 @@ namespace pxsim {
}
}
export class Image {
export class Image extends RefObject {
public static height: number = 5;
public width: number;
public data: number[];
constructor(width: number, data: number[]) {
super()
this.width = width;
this.data = data;
}
public print() {
console.log(`Image id:${this.id} refs:${this.refcnt} size:${this.width}x${Image.height}`)
}
public get(x: number, y: number): number {
if (x < 0 || x >= this.width || y < 0 || y >= 5) return 0;
return this.data[y * this.width + x];
@ -650,6 +655,12 @@ namespace pxsim {
}
}
export function createInternalImage(width: number): Image {
let img = createImage(width)
pxsim.noLeakTracking(img)
return img
}
export function createImage(width: number): Image {
return new Image(width, new Array(width * 5));
}
@ -661,7 +672,7 @@ namespace pxsim {
export function createImageFromString(text: string): Image {
let font = board().font;
let w = font.width;
let sprite = createImage(6 * text.length - 1);
let sprite = createInternalImage(6 * text.length - 1);
let k = 0;
for (let i = 0; i < text.length; i++) {
let charCode = text.charCodeAt(i);
@ -685,7 +696,7 @@ namespace pxsim {
let nb = data.length;
let n = nb / 5;
let font = createImage(nb);
let font = createInternalImage(nb);
for (let c = 0; c < n; c++) {
for (let row = 0; row < 5; row++) {
let char = data[c * 5 + row];