Merge pull request #240 from Microsoft/neopixel-improvement

improves neopixel simulator
This commit is contained in:
Peli de Halleux 2016-09-07 11:22:40 -07:00 committed by GitHub
commit 7a9f382bee

View File

@ -102,26 +102,18 @@ namespace pxsim.visuals {
}); });
return { el: img, x: l, y: t, w: w, h: h }; return { el: img, x: l, y: t, w: w, h: h };
} }
export class NeoPixel implements SVGAndSize<SVGCircleElement> { export class NeoPixel {
public el: SVGCircleElement; public el: SVGElement;
public w: number;
public h: number;
public x: number;
public y: number;
public cx: number;
public cy: number; public cy: number;
constructor(xy: Coord = [0, 0]) { constructor(xy: Coord = [0, 0]) {
let circle = <SVGCircleElement>svg.elt("circle"); let circle = <SVGElement>svg.elt("rect");
let r = PIXEL_RADIUS; let r = PIXEL_RADIUS;
let [cx, cy] = xy; let [cx, cy] = xy;
svg.hydrate(circle, { cx: cx, cy: cy, r: r, class: "sim-neopixel" }); let y = cy - r;
let x = 0;
svg.hydrate(circle, { x: "-50%", y: y, width: "100%", height: r*2, class: "sim-neopixel" });
this.el = circle; this.el = circle;
this.w = r * 2;
this.h = r * 2;
this.x = cx - r;
this.y = cy - r;
this.cx = cx;
this.cy = cy; this.cy = cy;
} }