2018-07-12 12:53:49 +00:00
|
|
|
import { Point } from './point'
|
2018-07-14 16:04:39 +00:00
|
|
|
import { Path } from './path'
|
2018-07-16 13:42:26 +00:00
|
|
|
import { Snippet } from './snippet'
|
2018-07-14 16:04:39 +00:00
|
|
|
import { Attributes } from './attributes'
|
2018-07-10 19:29:09 +02:00
|
|
|
|
2018-07-16 20:09:12 +02:00
|
|
|
function PointProxy(id: string) {
|
|
|
|
this.id = id;
|
2018-07-17 14:16:17 +00:00
|
|
|
this.get = function(points: any, key: string, proxy: ProxyHandler<Map<any, any>>): Point {
|
2018-07-16 19:48:47 +02:00
|
|
|
return points.get(key);
|
2018-07-16 20:09:12 +02:00
|
|
|
};
|
|
|
|
this.set = function(points: Map<string, Point>, key: string, point: Point, proxy: ProxyHandler<Map<any, any>>) {
|
2018-07-16 19:48:47 +02:00
|
|
|
point.attributes.add('data-key', key);
|
|
|
|
point.attributes.add('data-part', this.id);
|
|
|
|
points.set(key, point);
|
|
|
|
return true;
|
2018-07-16 20:09:12 +02:00
|
|
|
};
|
2018-07-16 19:48:47 +02:00
|
|
|
};
|
|
|
|
|
2018-07-12 12:53:49 +00:00
|
|
|
export class Part {
|
|
|
|
id: string;
|
|
|
|
render: boolean;
|
2018-07-16 20:09:12 +02:00
|
|
|
points: any;
|
2018-07-14 16:04:39 +00:00
|
|
|
paths: { [index: string]: Path; } = {};
|
2018-07-16 13:42:26 +00:00
|
|
|
snippets: { [index: string]: Snippet; } = {};
|
2018-07-14 16:04:39 +00:00
|
|
|
attributes = new Attributes();
|
2018-07-11 12:45:02 +00:00
|
|
|
[propName: string]: any;
|
2018-07-10 19:29:09 +02:00
|
|
|
|
2018-07-12 12:53:49 +00:00
|
|
|
constructor(id: string) {
|
2018-07-10 19:29:09 +02:00
|
|
|
this.id = id;
|
2018-07-12 12:53:49 +00:00
|
|
|
this.render = (id.substr(0,1) === '_') ? false : true;
|
2018-07-16 20:09:12 +02:00
|
|
|
this.points = new Proxy(new Map(), new PointProxy(id));
|
2018-07-16 15:20:50 +00:00
|
|
|
this.points.origin = new Point(0,0);
|
2018-07-10 19:29:09 +02:00
|
|
|
|
|
|
|
return this;
|
|
|
|
}
|
2018-07-12 12:53:49 +00:00
|
|
|
// purge = {
|
|
|
|
// points = function(prefix: string): void {}
|
|
|
|
// paths = function(prefix: string): void {}
|
|
|
|
// }
|
2018-07-10 19:29:09 +02:00
|
|
|
}
|