mirror of
https://github.com/konvajs/konva.git
synced 2025-11-18 17:21:36 +08:00
fixed up Canvas type bug. The Canvas constructor can now also take an optional isBuffer param. If not defined, default value is scene
This commit is contained in:
@@ -39,9 +39,7 @@ Kinetic.Layer.prototype = {
|
||||
this.afterDrawFunc = undefined;
|
||||
this.canvas = new Kinetic.Canvas();
|
||||
this.canvas.getElement().style.position = 'absolute';
|
||||
this.canvas.getContext().type = 'scene';
|
||||
this.bufferCanvas = new Kinetic.Canvas();
|
||||
this.bufferCanvas.getContext().type = 'buffer';
|
||||
this.bufferCanvas = new Kinetic.Canvas(0, 0, true);
|
||||
|
||||
// call super constructor
|
||||
Kinetic.Container.call(this, config);
|
||||
|
||||
@@ -732,7 +732,7 @@ Kinetic.Node.prototype = {
|
||||
canvas = new Kinetic.Canvas(config.width, config.height);
|
||||
}
|
||||
else {
|
||||
canvas = this.getStage().bufferCanvas;
|
||||
canvas = this.getStage().canvas;
|
||||
canvas.clear();
|
||||
}
|
||||
|
||||
|
||||
@@ -563,9 +563,7 @@ Kinetic.Stage.prototype = {
|
||||
this.attrs.container.appendChild(this.content);
|
||||
|
||||
this.canvas = new Kinetic.Canvas();
|
||||
this.canvas.getContext().type = 'scene';
|
||||
this.bufferCanvas = new Kinetic.Canvas();
|
||||
this.bufferCanvas.getContext().type = 'buffer';
|
||||
this.bufferCanvas = new Kinetic.Canvas(0, 0, true);
|
||||
|
||||
this._resizeDOM();
|
||||
},
|
||||
|
||||
@@ -4,13 +4,16 @@
|
||||
* @param {Number} width
|
||||
* @param {Number} height
|
||||
*/
|
||||
Kinetic.Canvas = function(width, height) {
|
||||
Kinetic.Canvas = function(width, height, isBuffer) {
|
||||
this.element = document.createElement('canvas');
|
||||
this.context = this.element.getContext('2d');
|
||||
|
||||
// set dimensions
|
||||
this.element.width = width || 0;
|
||||
this.element.height = height || 0;
|
||||
|
||||
// set type
|
||||
this.context.type = isBuffer ? 'buffer' : 'scene';
|
||||
};
|
||||
|
||||
Kinetic.Canvas.prototype = {
|
||||
|
||||
Reference in New Issue
Block a user