2.0 first commit
This commit is contained in:
39
src/drawing/two-point-drawing.ts
Normal file
39
src/drawing/two-point-drawing.ts
Normal file
@ -0,0 +1,39 @@
|
||||
import { Point } from './data-source';
|
||||
import { DrawingOptions, defaultOptions } from './options';
|
||||
import { Drawing } from './drawing';
|
||||
import { TwoPointDrawingPaneView } from './pane-view';
|
||||
|
||||
|
||||
export abstract class TwoPointDrawing extends Drawing {
|
||||
_p1: Point;
|
||||
_p2: Point;
|
||||
_paneViews: TwoPointDrawingPaneView[] = [];
|
||||
|
||||
constructor(
|
||||
p1: Point,
|
||||
p2: Point,
|
||||
options?: Partial<DrawingOptions>
|
||||
) {
|
||||
super()
|
||||
this._p1 = p1;
|
||||
this._p2 = p2;
|
||||
this._options = {
|
||||
...defaultOptions,
|
||||
...options,
|
||||
};
|
||||
}
|
||||
|
||||
setFirstPoint(point: Point) {
|
||||
this.updatePoints(point);
|
||||
}
|
||||
|
||||
setSecondPoint(point: Point) {
|
||||
this.updatePoints(null, point);
|
||||
}
|
||||
|
||||
public updatePoints(...points: (Point|null)[]) {
|
||||
this._p1 = points[0] || this._p1;
|
||||
this._p2 = points[1] || this._p2;
|
||||
this.requestUpdate();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user