mirror of
https://github.com/konvajs/konva.git
synced 2025-09-18 18:27:58 +08:00
layer.toDataURL() now directly returns layer canvas data url if position and size are not specificed. updated unit tests and docs
This commit is contained in:
@@ -4,29 +4,6 @@
|
||||
* @constructor
|
||||
* @augments Kinetic.Node
|
||||
* @param {Object} config
|
||||
* @param {Number} [config.x]
|
||||
* @param {Number} [config.y]
|
||||
* @param {Boolean} [config.visible]
|
||||
* @param {Boolean} [config.listening] whether or not the node is listening for events
|
||||
* @param {String} [config.id] unique id
|
||||
* @param {String} [config.name] non-unique name
|
||||
* @param {Number} [config.alpha] determines node opacity. Can be any number between 0 and 1
|
||||
* @param {Object} [config.scale]
|
||||
* @param {Number} [config.scale.x]
|
||||
* @param {Number} [config.scale.y]
|
||||
* @param {Number} [config.rotation] rotation in radians
|
||||
* @param {Number} [config.rotationDeg] rotation in degrees
|
||||
* @param {Object} [config.offset] offsets default position point and rotation point
|
||||
* @param {Number} [config.offset.x]
|
||||
* @param {Number} [config.offset.y]
|
||||
* @param {Boolean} [config.draggable]
|
||||
* @param {String} [config.dragConstraint] can be vertical, horizontal, or none. The default
|
||||
* is none
|
||||
* @param {Object} [config.dragBounds]
|
||||
* @param {Number} [config.dragBounds.top]
|
||||
* @param {Number} [config.dragBounds.right]
|
||||
* @param {Number} [config.dragBounds.bottom]
|
||||
* @param {Number} [config.dragBounds.left]
|
||||
*/
|
||||
Kinetic.Container = function(config) {
|
||||
this._containerInit(config);
|
||||
|
13
src/Layer.js
13
src/Layer.js
@@ -71,6 +71,19 @@
|
||||
}
|
||||
Kinetic.Container.prototype.drawScene.call(this, canvas);
|
||||
},
|
||||
toDataURL: function(config) {
|
||||
config = config || {};
|
||||
var mimeType = config.mimeType || null, quality = config.quality || null, canvas, context, x = config.x || 0, y = config.y || 0;
|
||||
|
||||
// if dimension or position is defined, use Node toDataURL
|
||||
if(config.width || config.height || config.x || config.y) {
|
||||
return Kinetic.Node.prototype.toDataURL.call(this, config);
|
||||
}
|
||||
// otherwise get data url of the currently drawn layer
|
||||
else {
|
||||
return this.getCanvas().toDataURL(mimeType, quality);
|
||||
}
|
||||
},
|
||||
/**
|
||||
* set before draw handler
|
||||
* @name beforeDraw
|
||||
|
File diff suppressed because one or more lines are too long
@@ -102,7 +102,7 @@ Test.prototype = {
|
||||
if(key.charAt(0) !== '!' && (!testOnlySpecial || key.charAt(0) === '*')) {
|
||||
var obj = this.addTestContainer(key);
|
||||
this.counter++;
|
||||
console.log(this.counter + ') ' + key);
|
||||
console.log(this.counter + ') ' + mod + ' - ' + key);
|
||||
tests[key](key);
|
||||
obj.testMessage.innerHTML = this.counter + ') ' + mod + ' - ' + key + ': PASSED';
|
||||
obj.testMessage.setAttribute('class', 'gray');
|
||||
|
@@ -76,12 +76,10 @@ Test.Modules.SHAPE = {
|
||||
strokeWidth: 4,
|
||||
id: 'myTriangle',
|
||||
draggable: true,
|
||||
shadow: {
|
||||
color: 'black',
|
||||
opacity: 0.5,
|
||||
blur: 10,
|
||||
offset: 10
|
||||
}
|
||||
shadowColor: 'black',
|
||||
shadowOpacity: 0.5,
|
||||
shadowBlur: 10,
|
||||
shadowOffset: 10
|
||||
});
|
||||
|
||||
stage.add(layer.add(triangle));
|
||||
|
@@ -228,6 +228,8 @@ Test.Modules.Text = {
|
||||
|
||||
layer.add(text);
|
||||
stage.add(layer);
|
||||
|
||||
//console.log(layer.toDataURL());
|
||||
|
||||
warn(layer.toDataURL() === dataUrls['multiline text with shadows'], 'multi line text with shadows data url is incorrect');
|
||||
},
|
||||
|
Reference in New Issue
Block a user