2016-08-30 20:55:00 +02:00
|
|
|
|
|
|
|
namespace pxsim.visuals {
|
2016-09-01 04:37:20 +02:00
|
|
|
export function mkGenericPartSVG(partVisual: PartVisualDefinition): SVGAndSize<SVGImageElement> {
|
|
|
|
let imgAndSize = mkImageSVG({
|
|
|
|
image: partVisual.image,
|
|
|
|
width: partVisual.width,
|
|
|
|
height: partVisual.height,
|
2016-09-09 10:23:39 +02:00
|
|
|
imageUnitDist: partVisual.pinDistance,
|
2016-09-01 04:37:20 +02:00
|
|
|
targetUnitDist: PIN_DIST
|
|
|
|
});
|
|
|
|
return imgAndSize;
|
|
|
|
}
|
|
|
|
|
2016-09-09 10:23:39 +02:00
|
|
|
export class GenericPart implements IBoardPart<any> {
|
2016-09-01 04:01:59 +02:00
|
|
|
public style: string = "";
|
2016-08-30 20:55:00 +02:00
|
|
|
public element: SVGElement;
|
2016-09-01 04:01:59 +02:00
|
|
|
defs: SVGElement[] = [];
|
|
|
|
|
|
|
|
constructor(partVisual: PartVisualDefinition) {
|
2016-09-01 04:37:20 +02:00
|
|
|
let imgAndSize = mkGenericPartSVG(partVisual);
|
2016-09-01 04:01:59 +02:00
|
|
|
let img = imgAndSize.el;
|
|
|
|
this.element = svg.elt("g");
|
|
|
|
this.element.appendChild(img);
|
2016-08-30 20:55:00 +02:00
|
|
|
}
|
2016-09-01 04:01:59 +02:00
|
|
|
|
2016-08-30 20:55:00 +02:00
|
|
|
moveToCoord(xy: Coord): void {
|
2016-09-01 04:01:59 +02:00
|
|
|
translateEl(this.element, xy);
|
2016-08-30 20:55:00 +02:00
|
|
|
}
|
2016-09-01 04:01:59 +02:00
|
|
|
|
|
|
|
//unused
|
2016-09-09 10:23:39 +02:00
|
|
|
init(bus: EventBus, state: any, svgEl: SVGSVGElement): void { }
|
2016-09-01 04:01:59 +02:00
|
|
|
updateState(): void { }
|
|
|
|
updateTheme(): void { }
|
2016-08-30 20:55:00 +02:00
|
|
|
}
|
|
|
|
}
|