mirror of
https://github.com/konvajs/konva.git
synced 2025-12-04 10:58:22 +08:00
added data url support for Kinetic.Image, and added unit tests
This commit is contained in:
18
dist/kinetic-core.js
vendored
18
dist/kinetic-core.js
vendored
@@ -80,15 +80,18 @@ Kinetic.Type = {
|
||||
_isFunction: function(obj) {
|
||||
return !!(obj && obj.constructor && obj.call && obj.apply);
|
||||
},
|
||||
_isArray: function(obj) {
|
||||
return Object.prototype.toString.call(obj) == '[object Array]';
|
||||
},
|
||||
_isObject: function(obj) {
|
||||
return (!!obj && obj.constructor == Object);
|
||||
},
|
||||
_isArray: function(obj) {
|
||||
return Object.prototype.toString.call(obj) == '[object Array]';
|
||||
},
|
||||
_isNumber: function(obj) {
|
||||
return Object.prototype.toString.call(obj) == '[object Number]';
|
||||
},
|
||||
_isString: function(obj) {
|
||||
return Object.prototype.toString.call(obj) == '[object String]';
|
||||
},
|
||||
/*
|
||||
* other utils
|
||||
*/
|
||||
@@ -280,7 +283,14 @@ Kinetic.Type = {
|
||||
return arg;
|
||||
}
|
||||
|
||||
//if arg is image data, then convert it
|
||||
// if arg is a string, then it's a data url
|
||||
if(this._isString(arg)) {
|
||||
var imageObj = new Image();
|
||||
imageObj.src = arg;
|
||||
return imageObj;
|
||||
}
|
||||
|
||||
//if arg is an object that contains the data property, it's an image object
|
||||
if(arg.data) {
|
||||
var canvas = document.createElement('canvas');
|
||||
canvas.width = arg.width;
|
||||
|
||||
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
Reference in New Issue
Block a user