pxt-calliope/sim/visuals/genericpart.ts

35 lines
1.1 KiB
TypeScript
Raw Normal View History

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