adds support for generic components
This commit is contained in:
@@ -1,16 +1,35 @@
|
||||
|
||||
namespace pxsim.visuals {
|
||||
export class GenericComponentView implements IBoardComponent<any> {
|
||||
public style: string;
|
||||
export class GenericPart implements IBoardComponent<any> {
|
||||
public style: string = "";
|
||||
public element: SVGElement;
|
||||
defs: SVGElement[];
|
||||
init(bus: EventBus, state: any, svgEl: SVGSVGElement, gpioPins: string[], otherArgs: string[]): void {
|
||||
defs: SVGElement[] = [];
|
||||
|
||||
constructor(partVisual: PartVisualDefinition) {
|
||||
let imgAndSize = mkImageSVG({
|
||||
image: partVisual.image,
|
||||
width: partVisual.width,
|
||||
height: partVisual.height,
|
||||
imageUnitDist: partVisual.pinDist,
|
||||
targetUnitDist: PIN_DIST
|
||||
});
|
||||
let img = imgAndSize.el;
|
||||
let scaleFn = mkScaleFn(partVisual.pinDist, PIN_DIST);
|
||||
let [pinX, pinY] = partVisual.firstPin;
|
||||
let left = -scaleFn(pinX);
|
||||
let top = -scaleFn(pinY);
|
||||
translateEl(img, [left, top]); // So that 0,0 is on the first pin
|
||||
this.element = svg.elt("g");
|
||||
this.element.appendChild(img);
|
||||
}
|
||||
|
||||
moveToCoord(xy: Coord): void {
|
||||
translateEl(this.element, xy);
|
||||
}
|
||||
updateState(): void {
|
||||
}
|
||||
updateTheme(): void {
|
||||
}
|
||||
|
||||
//unused
|
||||
init(bus: EventBus, state: any, svgEl: SVGSVGElement, gpioPins: string[], otherArgs: string[]): void { }
|
||||
updateState(): void { }
|
||||
updateTheme(): void { }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user