namespace pxsim.visuals {
const SCREEN_PART_WIDTH = 158.439;
const SCREEN_PART_HEIGHT = 146.803;
const SCREEN_PART = `
`;
export function mkScreenPart(xy: Coord = [0, 0]): SVGElAndSize {
let [x, y] = xy;
let l = x;
let t = y;
let w = SCREEN_PART_WIDTH;
let h = SCREEN_PART_HEIGHT;
let img = svg.elt("image");
svg.hydrate(img, {
class: "sim-screen", x: l, y: t, width: w, height: h,
href: svg.toDataUri(SCREEN_PART)
});
return { el: img, x: l, y: t, w: w, h: h };
}
export class ScreenView implements IBoardPart {
bus: pxsim.EventBus;
style: string;
element: SVGElement;
overElement?: SVGElement;
defs: SVGElement[];
state: ScreenState;
canvas: SVGImageElement;
lastLocation: Coord;
constructor() {
}
init(bus: EventBus, state: ScreenState, svgEl: SVGSVGElement, otherParams: Map): void {
this.bus = bus;
this.state = state;
this.overElement = undefined;
this.defs = [];
this.lastLocation = [0, 0];
const partSvg = svg.parseString(SCREEN_PART);
this.canvas = partSvg.getElementById('thescreen') as SVGImageElement;
this.element = svg.elt("g");
this.element.appendChild(partSvg.firstElementChild as SVGElement);
this.state.bindToSvgImage(this.canvas);
}
moveToCoord(xy: visuals.Coord): void {
let [x, y] = xy;
const loc: Coord = [x, y];
this.lastLocation = loc;
this.updateLoc();
}
private updateLoc() {
let [x, y] = this.lastLocation;
translateEl(this.element, [x, y])
}
updateState(): void { }
updateTheme(): void { }
}
}