diff --git a/sim/definitions.ts b/sim/definitions.ts
index 685284e6..a8374580 100644
--- a/sim/definitions.ts
+++ b/sim/definitions.ts
@@ -165,7 +165,40 @@ namespace pxsim {
},
"speaker": {
visual: {
- image: "/parts/speaker.svg",
+ image: svg.toDataUri(``),
width: 500,
height: 500,
firstPin: [180, 135],
diff --git a/sim/visuals/neopixel.ts b/sim/visuals/neopixel.ts
index 2cdc73a8..9f65bfee 100644
--- a/sim/visuals/neopixel.ts
+++ b/sim/visuals/neopixel.ts
@@ -59,16 +59,48 @@ namespace pxsim.visuals {
const NP_PART_YOFF = -11;
const NP_PART_WIDTH = 87.5;
const NP_PART_HEIGHT = 190;
- const NEOPIXEL_PART_IMG = "neopixel.svg";
+ const NEOPIXEL_PART_IMG = ``;
let [x, y] = xy;
let l = x + NP_PART_XOFF;
let t = y + NP_PART_YOFF;
let w = NP_PART_WIDTH;
let h = NP_PART_HEIGHT;
let img = svg.elt("image");
- svg.hydrate(img, {class: "sim-neopixel-strip", x: l, y: t, width: w, height: h,
- href: `/parts/${NEOPIXEL_PART_IMG}`});
- return {el: img, x: l, y: t, w: w, h: h};
+ svg.hydrate(img, {
+ class: "sim-neopixel-strip", x: l, y: t, width: w, height: h,
+ href: svg.toDataUri(NEOPIXEL_PART_IMG)
+ });
+ return { el: img, x: l, y: t, w: w, h: h };
}
export class NeoPixel implements SVGAndSize {
public el: SVGCircleElement;
@@ -83,7 +115,7 @@ namespace pxsim.visuals {
let circle = svg.elt("circle");
let r = PIXEL_RADIUS;
let [cx, cy] = xy;
- svg.hydrate(circle, {cx: cx, cy: cy, r: r, class: "sim-neopixel"});
+ svg.hydrate(circle, { cx: cx, cy: cy, r: r, class: "sim-neopixel" });
this.el = circle;
this.w = r * 2;
this.h = r * 2;
@@ -121,14 +153,14 @@ namespace pxsim.visuals {
"height": `${CANVAS_HEIGHT}px`,
});
this.canvas = el;
- this.background = svg.child(el, "rect", { class: "sim-neopixel-background hidden"});
+ this.background = svg.child(el, "rect", { class: "sim-neopixel-background hidden" });
this.updateViewBox(-CANVAS_VIEW_WIDTH / 2, 0, CANVAS_VIEW_WIDTH, CANVAS_VIEW_HEIGHT);
}
private updateViewBox(x: number, y: number, w: number, h: number) {
this.viewBox = [x, y, w, h];
- svg.hydrate(this.canvas, {"viewBox": `${x} ${y} ${w} ${h}`});
- svg.hydrate(this.background, {"x": x, "y": y, "width": w, "height": h});
+ svg.hydrate(this.canvas, { "viewBox": `${x} ${y} ${w} ${h}` });
+ svg.hydrate(this.background, { "x": x, "y": y, "width": w, "height": h });
}
public update(colors: RGBW[]) {
@@ -144,7 +176,7 @@ namespace pxsim.visuals {
}
let color = colors[i];
pixel.setRgb(color);
- svg.hydrate(pixel.el, {title: `offset: ${i}`});
+ svg.hydrate(pixel.el, { title: `offset: ${i}` });
}
//show the canvas if it's hidden
@@ -164,7 +196,7 @@ namespace pxsim.visuals {
public setLoc(xy: Coord) {
let [x, y] = xy;
- svg.hydrate(this.canvas, {x: x, y: y});
+ svg.hydrate(this.canvas, { x: x, y: y });
}
};
@@ -232,7 +264,7 @@ namespace pxsim.visuals {
this.stripGroup.appendChild(part.el);
let canvas = new NeoPixelCanvas(this.pin);
this.canvas = canvas;
- let canvasG = svg.child(this.stripGroup, "g", {class: "sim-neopixel-canvas-parent"});
+ let canvasG = svg.child(this.stripGroup, "g", { class: "sim-neopixel-canvas-parent" });
canvasG.appendChild(canvas.canvas);
this.updateStripLoc();
}
@@ -245,12 +277,12 @@ namespace pxsim.visuals {
private updateStripLoc() {
let [x, y] = this.lastLocation;
this.canvas.setLoc([x + CANVAS_LEFT, y + CANVAS_TOP]);
- svg.hydrate(this.part.el, {transform: `translate(${x} ${y})`}); //TODO: update part's l,h, etc.
+ svg.hydrate(this.part.el, { transform: `translate(${x} ${y})` }); //TODO: update part's l,h, etc.
}
public updateState(): void {
let colors = this.state.getColors(this.pin, this.mode);
this.canvas.update(colors);
}
- public updateTheme (): void { }
+ public updateTheme(): void { }
}
}
\ No newline at end of file