mirror of
https://github.com/konvajs/konva.git
synced 2025-10-08 00:14:23 +08:00
fix stage.toDataURL defaults
This commit is contained in:
2
konva.js
2
konva.js
@@ -2,7 +2,7 @@
|
||||
* Konva JavaScript Framework v2.0.2
|
||||
* http://konvajs.github.io/
|
||||
* Licensed under the MIT
|
||||
* Date: Wed Apr 18 2018
|
||||
* Date: Thu Apr 19 2018
|
||||
*
|
||||
* Original work Copyright (C) 2011 - 2013 by Eric Rowell (KineticJS)
|
||||
* Modified work Copyright (C) 2014 - present by Anton Lavrenov (Konva)
|
||||
|
2
konva.min.js
vendored
2
konva.min.js
vendored
@@ -2,7 +2,7 @@
|
||||
* Konva JavaScript Framework v2.0.2
|
||||
* http://konvajs.github.io/
|
||||
* Licensed under the MIT
|
||||
* Date: Wed Apr 18 2018
|
||||
* Date: Thu Apr 19 2018
|
||||
*
|
||||
* Original work Copyright (C) 2011 - 2013 by Eric Rowell (KineticJS)
|
||||
* Modified work Copyright (C) 2014 - present by Anton Lavrenov (Konva)
|
||||
|
@@ -1641,7 +1641,7 @@
|
||||
* @param {Number} [config.quality] jpeg quality. If using an "image/jpeg" mimeType,
|
||||
* you can specify the quality from 0 to 1, where 0 is very poor quality and 1
|
||||
* is very high quality
|
||||
* @paremt {Number} [config.pixelRatio] pixelRatio of ouput image url. Default is 1
|
||||
* @param {Number} [config.pixelRatio] pixelRatio of output image url. Default is 1
|
||||
* @returns {String}
|
||||
*/
|
||||
toDataURL: function(config) {
|
||||
|
18
src/Stage.js
18
src/Stage.js
@@ -232,22 +232,6 @@
|
||||
getContent: function() {
|
||||
return this.content;
|
||||
},
|
||||
/**
|
||||
* Creates a composite data URL
|
||||
* @method
|
||||
* @memberof Konva.Stage.prototype
|
||||
* @param {Object} config
|
||||
* @param {Function} [config.callback] function executed when the composite has completed. Deprecated as method is sync now.
|
||||
* @param {String} [config.mimeType] can be "image/png" or "image/jpeg".
|
||||
* "image/png" is the default
|
||||
* @param {Number} [config.x] x position of canvas section
|
||||
* @param {Number} [config.y] y position of canvas section
|
||||
* @param {Number} [config.width] width of canvas section
|
||||
* @param {Number} [config.height] height of canvas section
|
||||
* @param {Number} [config.quality] jpeg quality. If using an "image/jpeg" mimeType,
|
||||
* you can specify the quality from 0 to 1, where 0 is very poor quality and 1
|
||||
* is very high quality
|
||||
*/
|
||||
toDataURL: function(config) {
|
||||
config = config || {};
|
||||
|
||||
@@ -258,7 +242,7 @@
|
||||
canvas = new Konva.SceneCanvas({
|
||||
width: config.width || this.getWidth(),
|
||||
height: config.height || this.getHeight(),
|
||||
pixelRatio: config.pixelRatio
|
||||
pixelRatio: config.pixelRatio || 1
|
||||
}),
|
||||
_context = canvas.getContext()._context,
|
||||
layers = this.children;
|
||||
|
@@ -1130,4 +1130,17 @@ suite('Stage', function() {
|
||||
stage.draw();
|
||||
assert.equal(stage.getIntersection(pos), circle, 'circle again');
|
||||
});
|
||||
|
||||
test.only('toDataURL should use pixelRatio 1 by default', function(done) {
|
||||
var stage = addStage();
|
||||
|
||||
var url = stage.toDataURL();
|
||||
var image = new window.Image();
|
||||
image.onload = function() {
|
||||
assert.equal(image.width, stage.width());
|
||||
assert.equal(image.height, stage.height());
|
||||
done();
|
||||
};
|
||||
image.src = url;
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user