-
Notifications
You must be signed in to change notification settings - Fork 0
/
Context.js
33 lines (26 loc) · 1015 Bytes
/
Context.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import PrimitiveFactory from './primitives/PrimitiveFactory';
import CanvasRenderer from './renderers/CanvasRenderer';
import Vector2 from './math/Vector2';
import EventEmitter from './EventEmitter';
import * as ScaleUtils from './utils/ScaleUtils';
export default class Context {
constructor(options) {
this.wrapper = options.wrapper;
this.startRange = options.startRange;
this.zoomEnabled = options.zoomEnabled;
this.live = options.live;
this.center = this.startRange ?
ScaleUtils.getCenterFromRange(this.startRange) :
new Vector2();
this.zoom = 1;
this.events = new EventEmitter();
this.primitiveFactory = new PrimitiveFactory(this);
this.renderer = new CanvasRenderer(this.wrapper);
this.compositionRenderer = new CanvasRenderer();
this.interactionRenderer = new CanvasRenderer();
this.mousePos = new Vector2(-1, -1);
this.mouseCoord = new Vector2(-1, -1);
this.pxPerUnit = new Vector2(-1, -1);
this.clock = Date.now();
}
}