mirror of
https://github.com/konvajs/konva.git
synced 2025-06-28 00:14:29 +08:00
no longer auto clearing shape data. added new shape.clearData() method instead
This commit is contained in:
parent
30e8973956
commit
63c8dde6d5
13
dist/kinetic-core.js
vendored
13
dist/kinetic-core.js
vendored
@ -2166,7 +2166,7 @@ Kinetic.Shape.prototype = {
|
|||||||
/**
|
/**
|
||||||
* save shape data when using pixel detection.
|
* save shape data when using pixel detection.
|
||||||
*/
|
*/
|
||||||
save: function() {
|
saveData: function() {
|
||||||
var stage = this.getStage();
|
var stage = this.getStage();
|
||||||
var w = stage.attrs.width;
|
var w = stage.attrs.width;
|
||||||
var h = stage.attrs.height;
|
var h = stage.attrs.height;
|
||||||
@ -2180,6 +2180,12 @@ Kinetic.Shape.prototype = {
|
|||||||
var imageData = bufferLayerContext.getImageData(0, 0, w, h);
|
var imageData = bufferLayerContext.getImageData(0, 0, w, h);
|
||||||
this.data = imageData.data;
|
this.data = imageData.data;
|
||||||
},
|
},
|
||||||
|
/**
|
||||||
|
* clear shape data
|
||||||
|
*/
|
||||||
|
clearData: function() {
|
||||||
|
this.data = [];
|
||||||
|
},
|
||||||
/**
|
/**
|
||||||
* draw shape
|
* draw shape
|
||||||
* @param {Layer} layer Layer that the shape will be drawn on
|
* @param {Layer} layer Layer that the shape will be drawn on
|
||||||
@ -2211,11 +2217,6 @@ Kinetic.Shape.prototype = {
|
|||||||
this.drawFunc.call(this);
|
this.drawFunc.call(this);
|
||||||
context.restore();
|
context.restore();
|
||||||
}
|
}
|
||||||
|
|
||||||
// clear shape data
|
|
||||||
if(this.attrs.detectionType === 'pixel') {
|
|
||||||
this.data = [];
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* custom isPointInPath method which can use path detection
|
* custom isPointInPath method which can use path detection
|
||||||
|
4
dist/kinetic-core.min.js
vendored
4
dist/kinetic-core.min.js
vendored
File diff suppressed because one or more lines are too long
13
src/Shape.js
13
src/Shape.js
@ -155,7 +155,7 @@ Kinetic.Shape.prototype = {
|
|||||||
/**
|
/**
|
||||||
* save shape data when using pixel detection.
|
* save shape data when using pixel detection.
|
||||||
*/
|
*/
|
||||||
save: function() {
|
saveData: function() {
|
||||||
var stage = this.getStage();
|
var stage = this.getStage();
|
||||||
var w = stage.attrs.width;
|
var w = stage.attrs.width;
|
||||||
var h = stage.attrs.height;
|
var h = stage.attrs.height;
|
||||||
@ -169,6 +169,12 @@ Kinetic.Shape.prototype = {
|
|||||||
var imageData = bufferLayerContext.getImageData(0, 0, w, h);
|
var imageData = bufferLayerContext.getImageData(0, 0, w, h);
|
||||||
this.data = imageData.data;
|
this.data = imageData.data;
|
||||||
},
|
},
|
||||||
|
/**
|
||||||
|
* clear shape data
|
||||||
|
*/
|
||||||
|
clearData: function() {
|
||||||
|
this.data = [];
|
||||||
|
},
|
||||||
/**
|
/**
|
||||||
* draw shape
|
* draw shape
|
||||||
* @param {Layer} layer Layer that the shape will be drawn on
|
* @param {Layer} layer Layer that the shape will be drawn on
|
||||||
@ -200,11 +206,6 @@ Kinetic.Shape.prototype = {
|
|||||||
this.drawFunc.call(this);
|
this.drawFunc.call(this);
|
||||||
context.restore();
|
context.restore();
|
||||||
}
|
}
|
||||||
|
|
||||||
// clear shape data
|
|
||||||
if(this.attrs.detectionType === 'pixel') {
|
|
||||||
this.data = [];
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* custom isPointInPath method which can use path detection
|
* custom isPointInPath method which can use path detection
|
||||||
|
@ -679,7 +679,7 @@ Test.prototype.tests = {
|
|||||||
});
|
});
|
||||||
|
|
||||||
darth.on('dragend', function() {
|
darth.on('dragend', function() {
|
||||||
this.save();
|
this.saveData();
|
||||||
});
|
});
|
||||||
|
|
||||||
layer.add(darth);
|
layer.add(darth);
|
||||||
@ -723,13 +723,13 @@ Test.prototype.tests = {
|
|||||||
});
|
});
|
||||||
|
|
||||||
star.on('dragend', function() {
|
star.on('dragend', function() {
|
||||||
this.save();
|
this.saveData();
|
||||||
});
|
});
|
||||||
|
|
||||||
layer.add(star);
|
layer.add(star);
|
||||||
stage.add(layer);
|
stage.add(layer);
|
||||||
|
|
||||||
star.save();
|
star.saveData();
|
||||||
};
|
};
|
||||||
imageObj.src = '../lion.png';
|
imageObj.src = '../lion.png';
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user