Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function loadImage() {
// Note we cannot use fabric.Image.fromURL, as then we would always get
// fabric.Image instance and we couldn't guess whether load failed or not.
// util.loadImage provides null to callback when loading fails.
fabric.util.loadImage(imageSrc, callback, null, options.crossOrigin);
}
function callback (img) {
CloneTool.prototype.copy = function (callback) {
var activeObject = this.canvas.getActiveGroup() || this.canvas.getActiveObject();
if (!activeObject) {
return;
}
// We don't want to copy control point, but the source object instead.
// See: line-custom-control-points.js
if (activeObject._dt_sourceObj) {
activeObject = activeObject._dt_sourceObj;
}
var klass = fabric.util.getKlass(activeObject.type);
var propsToInclude = this.master.ADDITIONAL_PROPS_TO_SERIALIZE;
if (klass.async) {
activeObject.clone(function (clonedObject) {
this._updateClipboard(clonedObject);
if (typeof callback === 'function') {
callback();
}
}.bind(this), propsToInclude);
} else {
this._updateClipboard(activeObject.clone(null, propsToInclude));
if (typeof callback === 'function') {
callback();
}
}
};
'use strict';
var extend = fabric.util.object.extend;
if (fabric.Arrow) {
fabric.warn('fabric.Arrow is already defined');
return;
}
/**
* Arrow class
* @class fabric.Arrow
* @extends fabric.Line
* @see {@link fabric.Arrow#initialize} for constructor definition
*/
fabric.Arrow = fabric.util.createClass(fabric.Line, /** @lends fabric.Arrow.prototype */ {
/**
* Type of an object
* @type String
* @default
*/
type: 'arrow',
/**
* Type of the arrow (double or single)
* @type Boolean
* @default
*/
doubleArrowhead: false,
/**
StampTool.prototype._loadNonSVGImage = function (url, callback) {
fabric.util.loadImage(url, function (img) {
var fabricObj = new fabric.Image(img, {
crossOrigin: img.crossOrigin
});
fabricObj._dt_sourceURL = url;
callback(fabricObj, img)
}, null, 'anonymous');
};
function LineTool(name, drawTool, lineType, lineOptions) {
ShapeTool.call(this, name, drawTool);
lineType = lineType || 'line';
this._lineKlass = fabric.util.getKlass(lineType);
this._lineOptions = lineOptions;
lineCustomControlPoints(this.canvas);
}
fabric.loadSVGFromURL(url, function (objects, options) {
var fabricObj = fabric.util.groupSVGElements(objects, options);
fabricObj._dt_sourceURL = url;
callback(fabricObj, this._renderToImage(fabricObj));
}.bind(this));
};
function BasicShapeTool(name, drawTool, type) {
ShapeTool.call(this, name, drawTool);
this._type = SUPPORTED_SHAPES[type];
this._shapeKlass = fabric.util.getKlass(this._type.fabricType);
}
(function() {
'use strict';
var extend = fabric.util.object.extend;
if (fabric.Arrow) {
fabric.warn('fabric.Arrow is already defined');
return;
}
/**
* Arrow class
* @class fabric.Arrow
* @extends fabric.Line
* @see {@link fabric.Arrow#initialize} for constructor definition
*/
fabric.Arrow = fabric.util.createClass(fabric.Line, /** @lends fabric.Arrow.prototype */ {
/**
* Type of an object