mirror of
https://github.com/konvajs/konva.git
synced 2025-09-18 18:27:58 +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.afterDrawFunc = undefined;
|
||||||
this.canvas = new Kinetic.Canvas();
|
this.canvas = new Kinetic.Canvas();
|
||||||
this.canvas.getElement().style.position = 'absolute';
|
this.canvas.getElement().style.position = 'absolute';
|
||||||
this.canvas.getContext().type = 'scene';
|
this.bufferCanvas = new Kinetic.Canvas(0, 0, true);
|
||||||
this.bufferCanvas = new Kinetic.Canvas();
|
|
||||||
this.bufferCanvas.getContext().type = 'buffer';
|
|
||||||
|
|
||||||
// call super constructor
|
// call super constructor
|
||||||
Kinetic.Container.call(this, config);
|
Kinetic.Container.call(this, config);
|
||||||
|
@@ -732,7 +732,7 @@ Kinetic.Node.prototype = {
|
|||||||
canvas = new Kinetic.Canvas(config.width, config.height);
|
canvas = new Kinetic.Canvas(config.width, config.height);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
canvas = this.getStage().bufferCanvas;
|
canvas = this.getStage().canvas;
|
||||||
canvas.clear();
|
canvas.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -563,9 +563,7 @@ Kinetic.Stage.prototype = {
|
|||||||
this.attrs.container.appendChild(this.content);
|
this.attrs.container.appendChild(this.content);
|
||||||
|
|
||||||
this.canvas = new Kinetic.Canvas();
|
this.canvas = new Kinetic.Canvas();
|
||||||
this.canvas.getContext().type = 'scene';
|
this.bufferCanvas = new Kinetic.Canvas(0, 0, true);
|
||||||
this.bufferCanvas = new Kinetic.Canvas();
|
|
||||||
this.bufferCanvas.getContext().type = 'buffer';
|
|
||||||
|
|
||||||
this._resizeDOM();
|
this._resizeDOM();
|
||||||
},
|
},
|
||||||
|
@@ -4,13 +4,16 @@
|
|||||||
* @param {Number} width
|
* @param {Number} width
|
||||||
* @param {Number} height
|
* @param {Number} height
|
||||||
*/
|
*/
|
||||||
Kinetic.Canvas = function(width, height) {
|
Kinetic.Canvas = function(width, height, isBuffer) {
|
||||||
this.element = document.createElement('canvas');
|
this.element = document.createElement('canvas');
|
||||||
this.context = this.element.getContext('2d');
|
this.context = this.element.getContext('2d');
|
||||||
|
|
||||||
// set dimensions
|
// set dimensions
|
||||||
this.element.width = width || 0;
|
this.element.width = width || 0;
|
||||||
this.element.height = height || 0;
|
this.element.height = height || 0;
|
||||||
|
|
||||||
|
// set type
|
||||||
|
this.context.type = isBuffer ? 'buffer' : 'scene';
|
||||||
};
|
};
|
||||||
|
|
||||||
Kinetic.Canvas.prototype = {
|
Kinetic.Canvas.prototype = {
|
||||||
|
@@ -72,8 +72,6 @@ Test.prototype = {
|
|||||||
|
|
||||||
// loop through modules
|
// loop through modules
|
||||||
for(var mod in modules) {
|
for(var mod in modules) {
|
||||||
console.log('=================== ' + mod + ' TESTS ===================');
|
|
||||||
|
|
||||||
var tests = modules[mod];
|
var tests = modules[mod];
|
||||||
/*
|
/*
|
||||||
* if a test key has a star in front of it, then
|
* if a test key has a star in front of it, then
|
||||||
@@ -86,6 +84,13 @@ Test.prototype = {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// loop through modules
|
||||||
|
for(var mod in modules) {
|
||||||
|
console.log('=================== ' + mod + ' TESTS ===================');
|
||||||
|
|
||||||
|
var tests = modules[mod];
|
||||||
|
|
||||||
// loop through tests
|
// loop through tests
|
||||||
for(var key in tests) {
|
for(var key in tests) {
|
||||||
|
@@ -622,7 +622,7 @@ Test.Modules.NODE = {
|
|||||||
clone.start();
|
clone.start();
|
||||||
};
|
};
|
||||||
imageObj.src = '../assets/scorpion-sprite.png';
|
imageObj.src = '../assets/scorpion-sprite.png';
|
||||||
},
|
},
|
||||||
'node caching': function(containerId) {
|
'node caching': function(containerId) {
|
||||||
var stage = new Kinetic.Stage({
|
var stage = new Kinetic.Stage({
|
||||||
container: containerId,
|
container: containerId,
|
||||||
@@ -668,6 +668,8 @@ Test.Modules.NODE = {
|
|||||||
width: 500,
|
width: 500,
|
||||||
height: 300,
|
height: 300,
|
||||||
callback: function(imageObj) {
|
callback: function(imageObj) {
|
||||||
|
|
||||||
|
//document.body.appendChild(imageObj)
|
||||||
test(Kinetic.Type._isElement(imageObj), 'shape toImage() should be an image object');
|
test(Kinetic.Type._isElement(imageObj), 'shape toImage() should be an image object');
|
||||||
|
|
||||||
var cachedShape = new Kinetic.Image({
|
var cachedShape = new Kinetic.Image({
|
||||||
@@ -694,6 +696,7 @@ Test.Modules.NODE = {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/*
|
||||||
group.toImage({
|
group.toImage({
|
||||||
callback: function(imageObj) {
|
callback: function(imageObj) {
|
||||||
test(Kinetic.Type._isElement(imageObj), 'group toImage() should be an image object');
|
test(Kinetic.Type._isElement(imageObj), 'group toImage() should be an image object');
|
||||||
@@ -709,6 +712,7 @@ Test.Modules.NODE = {
|
|||||||
test(Kinetic.Type._isElement(imageObj), 'stage toImage() should be an image object');
|
test(Kinetic.Type._isElement(imageObj), 'stage toImage() should be an image object');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
*/
|
||||||
|
|
||||||
//document.body.appendChild(layer.bufferCanvas.element)
|
//document.body.appendChild(layer.bufferCanvas.element)
|
||||||
},
|
},
|
||||||
|
Reference in New Issue
Block a user