60 lines
929 B
TypeScript
60 lines
929 B
TypeScript
import {Junction} from '../junction/Junction';
|
|
import {PartType} from './PartType';
|
|
|
|
export const RASTER = 50;
|
|
|
|
export abstract class Part {
|
|
|
|
protected constructor(
|
|
readonly x: number,
|
|
readonly y: number,
|
|
readonly type: PartType,
|
|
readonly junctions: Junction[],
|
|
readonly w: number = 3,
|
|
readonly h: number = 3,
|
|
) {
|
|
//
|
|
}
|
|
|
|
get xR(): number {
|
|
return this.x * RASTER;
|
|
}
|
|
|
|
get yR(): number {
|
|
return this.y * RASTER;
|
|
}
|
|
|
|
get wR(): number {
|
|
return this.w * RASTER;
|
|
}
|
|
|
|
get hR(): number {
|
|
return this.h * RASTER;
|
|
}
|
|
|
|
get xP(): string {
|
|
return this.xR + 'px';
|
|
}
|
|
|
|
get yP(): string {
|
|
return this.yR + 'px';
|
|
}
|
|
|
|
get wP(): string {
|
|
return this.wR + 'px';
|
|
}
|
|
|
|
get hP(): string {
|
|
return this.hR + 'px';
|
|
}
|
|
|
|
ngClass(): string[] {
|
|
return ['part', 'part' + this.type, ...this.ngClass2()];
|
|
}
|
|
|
|
protected ngClass2(): string[] {
|
|
return [];
|
|
}
|
|
|
|
}
|