Compare commits

...

26 Commits

Author SHA1 Message Date
0f273131f6 0.2.41 2016-04-07 09:46:17 -07:00
9ae0c48477 Bump kindscript to 0.2.42 2016-04-07 09:46:15 -07:00
5f538f418e 0.2.40 2016-04-07 09:18:35 -07:00
859b68b6e3 Bump kindscript to 0.2.41 2016-04-07 09:18:33 -07:00
6576f7bd66 better handlings of logs 2016-04-07 09:03:21 -07:00
5a670f3291 0.2.39 2016-04-07 06:45:52 -07:00
7129487618 0.2.38 2016-04-07 06:34:15 -07:00
e1797b457a Bump kindscript to 0.2.39 2016-04-07 06:34:14 -07:00
c82efa452d 0.2.37 2016-04-07 04:48:45 -07:00
493014af01 Bump kindscript to 0.2.38 2016-04-07 04:48:43 -07:00
fb4a96d81b 0.2.36 2016-04-07 03:56:24 -07:00
bbf115f33c Bump kindscript to 0.2.36 2016-04-07 03:56:22 -07:00
5d9c2cf590 svg refactored into kindsim 2016-04-07 03:52:32 -07:00
b99231f6e2 0.2.35 2016-04-06 18:24:27 -07:00
2676907129 Bump kindscript to 0.2.35 2016-04-06 18:24:25 -07:00
6f4c533ebb 0.2.34 2016-04-06 16:41:29 -07:00
85dcaea979 0.2.33 2016-04-06 16:36:41 -07:00
8560b31657 Bump kindscript to 0.2.33 2016-04-06 16:36:40 -07:00
b896588f45 0.2.32 2016-04-06 16:09:30 -07:00
0b4d4facfe fix target 2016-04-06 16:09:20 -07:00
52ad897ee3 0.2.31 2016-04-06 15:49:03 -07:00
72582f2a60 updated title 2016-04-06 15:48:45 -07:00
2b2048da7d 0.2.30 2016-04-06 15:34:37 -07:00
e85fa990bd Bump kindscript to 0.2.31 2016-04-06 15:34:35 -07:00
81a61538c3 updated target 2016-04-06 15:23:58 -07:00
cc8751bd09 updated target 2016-04-06 15:12:55 -07:00
4 changed files with 9 additions and 123 deletions

View File

@ -1,7 +1,7 @@
{ {
"id": "microbit", "id": "microbit",
"name": "BBC micro:bit", "name": "code micro:bit",
"title": "JavaScript for BBC micro:bit", "title": "micro:bit",
"corepkg": "microbit", "corepkg": "microbit",
"bundleddirs": [ "bundleddirs": [
"libs/microbit", "libs/microbit",
@ -22,13 +22,13 @@
"description": "", "description": "",
"files": [ "files": [
"main.blocks", "main.blocks",
"main.blocks.ts", "main.ts",
"README.md" "README.md"
] ]
}, },
"files": { "files": {
"main.blocks": "<xml xmlns=\"http://www.w3.org/1999/xhtml\"><block type=\"device_print_message\"><value name=\"text\"><shadow type=\"text\"><field name=\"TEXT\">Hello!</field></shadow></value></block></xml>", "main.blocks": "<xml xmlns=\"http://www.w3.org/1999/xhtml\"><block type=\"device_print_message\"><value name=\"text\"><shadow type=\"text\"><field name=\"TEXT\">Hello!</field></shadow></value></block></xml>",
"main.blocks.ts": "\n", "main.ts": "\n",
"README.md": "Describe your project here!" "README.md": "Describe your project here!"
} }
}, },

View File

@ -1,6 +1,6 @@
{ {
"name": "kindscript-microbit", "name": "kindscript-microbit",
"version": "0.2.29", "version": "0.2.41",
"description": "BBC micro:bit target for KindScript", "description": "BBC micro:bit target for KindScript",
"keywords": [ "keywords": [
"JavaScript", "JavaScript",
@ -29,6 +29,6 @@
"typescript": "^1.8.7" "typescript": "^1.8.7"
}, },
"dependencies": { "dependencies": {
"kindscript": "0.2.30" "kindscript": "0.2.42"
} }
} }

View File

@ -1,4 +1,5 @@
namespace ks.rt.micro_bit { namespace ks.rt.micro_bit {
const Svg = ks.rt.Svg;
export interface IBoardTheme { export interface IBoardTheme {
accent?: string; accent?: string;
@ -46,119 +47,6 @@ namespace ks.rt.micro_bit {
disableTilt?:boolean; disableTilt?:boolean;
} }
class Svg {
static pt : SVGPoint;
static cursorPoint(pt: SVGPoint, svg: SVGSVGElement, evt : MouseEvent) : SVGPoint {
pt.x = evt.clientX;
pt.y = evt.clientY;
return pt.matrixTransform(svg.getScreenCTM().inverse());
}
static rotateElement(el : SVGElement, originX : number ,originY : number,degrees:number){
el.setAttribute(
'transform',
`translate(${originX},${originY}) rotate(${degrees+90}) translate(${-originX},${-originY})`
);
}
static elt(name:string) : SVGElement {
return document.createElementNS("http://www.w3.org/2000/svg", name)
}
static hydrate(el : SVGElement, props: any) {
for(let k in props) {
if (k == "title") {
Svg.title(el, props[k])
} else el.setAttributeNS(null, k, props[k])
}
}
static child(parent : Element, name: string, props: any) : SVGElement {
var el = <SVGElement>Svg.elt(name);
Svg.hydrate(el, props);
parent.appendChild(el);
return el;
}
static path(parent: Element, cls: string, data:string, title?: string) : SVGElement {
let p : any = {class:cls, d:data};
if (title) p["title"] = title;
return Svg.child(parent, "path", p);
}
static fill(el: SVGElement, c : string) {
(<SVGStylable><any>el).style.fill = c;
}
static fills(els: SVGElement[], c : string) {
els.forEach(el => (<SVGStylable><any>el).style.fill = c);
}
static buttonEvents(el : Element,
move: (ev: MouseEvent) => void,
start?: (ev:MouseEvent) => void,
stop?: (ev:MouseEvent) => void) {
let captured = false;
el.addEventListener('mousedown', (ev: MouseEvent) => {
captured = true;
if (start) start(ev)
return true;
});
el.addEventListener('mousemove', (ev:MouseEvent) => {
if (captured) {
move(ev);
ev.preventDefault();
return false;
}
return true;
});
el.addEventListener('mouseup', (ev:MouseEvent) => {
captured = false;
if (stop) stop(ev);
});
el.addEventListener('mouseleave', (ev:MouseEvent) => {
captured = false;
if (stop) stop(ev);
});
}
static linearGradient(defs: SVGDefsElement, id : string) : SVGLinearGradientElement {
let gradient = <SVGLinearGradientElement>Svg.child(defs, "linearGradient", { id: id, x1:"0%", y1:"0%", x2:"0%", y2:"100%" });
let stop1 = Svg.child(gradient, "stop", {offset:"0%"})
let stop2 = Svg.child(gradient, "stop", {offset:"100%"})
let stop3 = Svg.child(gradient, "stop", {offset:"100%"})
let stop4 = Svg.child(gradient, "stop", {offset:"100%"})
return gradient;
}
static setGradientColors(lg : SVGLinearGradientElement, start:string, end:string) {
if (!lg) return;
(<SVGStopElement>lg.childNodes[0]).style.stopColor = start;
(<SVGStopElement>lg.childNodes[1]).style.stopColor = start;
(<SVGStopElement>lg.childNodes[2]).style.stopColor = end;
(<SVGStopElement>lg.childNodes[3]).style.stopColor = end;
}
static setGradientValue(lg : SVGLinearGradientElement, percent: string) {
(<SVGStopElement>lg.childNodes[1]).setAttribute("offset", percent);
(<SVGStopElement>lg.childNodes[2]).setAttribute("offset", percent);
}
static animate(el: SVGElement, cls: string) {
el.classList.add(cls);
let p = el.parentElement;
p.removeChild(el);
p.appendChild(el)
}
static title(el : SVGElement, txt:string) {
let t = Svg.child(el, "title", {});
t.textContent = txt;
}
}
export class MicrobitBoardSvg export class MicrobitBoardSvg
{ {
public element : SVGSVGElement; public element : SVGSVGElement;

View File

@ -596,8 +596,8 @@ namespace ks.rt {
writeSerial(s: string) { writeSerial(s: string) {
for (let i = 0; i < s.length; ++i) { for (let i = 0; i < s.length; ++i) {
let c = s[i]; let c = s[i];
switch (c) { this.serialOutBuffer += c;
case '\n': if (c == '\n') {
Runtime.postMessage(<SimulatorSerialMessage>{ Runtime.postMessage(<SimulatorSerialMessage>{
type: 'serial', type: 'serial',
data: this.serialOutBuffer, data: this.serialOutBuffer,
@ -605,8 +605,6 @@ namespace ks.rt {
}) })
this.serialOutBuffer = '' this.serialOutBuffer = ''
break; break;
case '\r': continue;
default: this.serialOutBuffer += c;
} }
} }
} }