mirror of
https://github.com/konvajs/konva.git
synced 2025-04-05 20:48:28 +08:00
37 lines
921 B
JavaScript
37 lines
921 B
JavaScript
Konva.WebGLLayer = function(config) {
|
|
this.nodeType = 'Layer';
|
|
this.canvas = new Konva.SceneWebGLCanvas();
|
|
this.hitCanvas = new Konva.HitCanvas({
|
|
pixelRatio: 1
|
|
});
|
|
// call super constructor
|
|
Konva.BaseLayer.call(this, config);
|
|
};
|
|
|
|
Konva.Util.extend(Konva.WebGLLayer, Konva.Layer);
|
|
|
|
Konva.SceneWebGLCanvas = function(config) {
|
|
var conf = config || {};
|
|
var width = conf.width || 0,
|
|
height = conf.height || 0;
|
|
|
|
Konva.Canvas.call(this, conf);
|
|
WebGL2D.enable(this._canvas);
|
|
this.context = new Konva.SceneWebGLContext(this);
|
|
this.setSize(width, height);
|
|
};
|
|
|
|
Konva.Util.extend(Konva.SceneWebGLCanvas, Konva.SceneCanvas);
|
|
|
|
Konva.SceneWebGLContext = function(canvas) {
|
|
this.canvas = canvas;
|
|
this._context = canvas._canvas.getContext('webgl-2d');
|
|
|
|
if (Konva.enableTrace) {
|
|
this.traceArr = [];
|
|
this._enableTrace();
|
|
}
|
|
};
|
|
|
|
Konva.Util.extend(Konva.SceneWebGLContext, Konva.SceneContext);
|