Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

fabric

Package Overview
Dependencies
Maintainers
2
Versions
309
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fabric - npm Package Compare versions

Comparing version 1.6.4 to 1.6.5

.eslintrc_tests

4

build.js

@@ -15,4 +15,4 @@ var fs = require('fs'),

var modulesToInclude = buildArgsAsObject.modules ? buildArgsAsObject.modules.split(',') : [ ];
var modulesToExclude = buildArgsAsObject.exclude ? buildArgsAsObject.exclude.split(',') : [ ];
var modulesToInclude = buildArgsAsObject.modules ? buildArgsAsObject.modules.split(',') : [];
var modulesToExclude = buildArgsAsObject.exclude ? buildArgsAsObject.exclude.split(',') : [];

@@ -19,0 +19,0 @@ var distributionPath = buildArgsAsObject.dest || 'dist/';

@@ -0,1 +1,24 @@

**Version 1.6.5**
- Fix: charspacing, do not get subzero with charwidth.
- Improvement: add callback support to all object cloning. [#3212](https://github.com/kangax/fabric.js/pull/3212)
- Improvement: add backgroundColor to all classe [#3248](https://github.com/kangax/fabric.js/pull/3248)
- Fix: add custom properties to backgroundImage and overlayImage [#3250](https://github.com/kangax/fabric.js/pull/3250)
- Fix: Object intersection is calculated on boundingBox and boundingRect, intersection is fired if objects are overlapping [#3252](https://github.com/kangax/fabric.js/pull/3252)
- Change: Restored previous selection behaviour, added key to selection active object under overlaid target [#3254](https://github.com/kangax/fabric.js/pull/3254)
- Improvement: hasStateChanged let you find state changes of complex properties. [#3262](https://github.com/kangax/fabric.js/pull/3262)
- Fix: IText/Textbox shift click selection backward. [#3270](https://github.com/kangax/fabric.js/pull/3270)
- Revert: font family quoting was a bad idea. node-canvas stills use it. [#3276](https://github.com/kangax/fabric.js/pull/3276)
- Fix: fire mouse:over event for activeObject and activeGroup when using findTarget shourtcuts [#3285](https://github.com/kangax/fabric.js/pull/3285)
- Fix: clear method clear all properties of canvas [#3305](https://github.com/kangax/fabric.js/pull/3305)
- Fix: text area position method takes in account canvas offset [#3306](https://github.com/kangax/fabric.js/pull/3306)
- Improvement: Added event on right click and possibility to hide the context menu with a flag [3308](https://github.com/kangax/fabric.js/pull/3308)
- Fix: remove canvas reference from object when object gets removed from canvas [#3307](https://github.com/kangax/fabric.js/pull/3307)
- Improvement: use native stroke dash if available [#3309](https://github.com/kangax/fabric.js/pull/3309)
- Fix: Export correct src when exporting to svg [#3310](https://github.com/kangax/fabric.js/pull/3310)
- Fix: Stop text to go on zero dimensions [#3312](https://github.com/kangax/fabric.js/pull/3312)
- Fix: Error in dataURL with multiplier was outputting very big canvas with retina [#3314](https://github.com/kangax/fabric.js/pull/3314)
- Fix: Error in style map was not respecting style if textbox started with space [#3315](https://github.com/kangax/fabric.js/pull/3315)
**Version 1.6.4**

@@ -2,0 +25,0 @@

@@ -27,3 +27,3 @@ <!--

## Version
1.6.2
1.6.5

@@ -30,0 +30,0 @@ ## Test Case

@@ -5,3 +5,3 @@ {

"homepage": "http://fabricjs.com/",
"version": "1.6.4",
"version": "1.6.5",
"author": "Juriy Zaytsev <kangax@gmail.com>",

@@ -42,4 +42,4 @@ "contributors": [

"test": "node test.js",
"lint": "jshint src && jscs src",
"lint_tests": "jshint test/unit --config .jshintrc_tests",
"lint": "eslint --config .eslintrc.json src",
"lint_tests": "eslint test/unit --config .eslintrc_tests",
"export_dist_to_site": "cp dist/fabric.js ../fabricjs.com/lib/fabric.js",

@@ -56,4 +56,3 @@ "export_tests_to_site": "cp test/unit/*.js ../fabricjs.com/test/unit",

"uglify-js": "2.7.x",
"jscs": "2.x.x",
"jshint": "2.9.x",
"eslint": "2.x.x",
"qunit": "0.9.x",

@@ -60,0 +59,0 @@ "istanbul": "0.4.x"

@@ -44,2 +44,3 @@ var testrunner = require('qunit');

'./test/unit/intersection.js',
'./test/unit/stateful.js'
]

@@ -46,0 +47,0 @@ }, function(err, report) {

@@ -1239,3 +1239,3 @@ /**

object:function( map ) {
var ret = [ ];
var ret = [];
QUnit.jsDump.up();

@@ -1242,0 +1242,0 @@ for ( var key in map )

@@ -5,38 +5,38 @@ (function() {

var CANVAS_SVG = '<?xml version="1.0" encoding="UTF-8" standalone="no" ?>\n<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">\n'+
var CANVAS_SVG = '<?xml version="1.0" encoding="UTF-8" standalone="no" ?>\n<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">\n' +
'<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="600" height="600" viewBox="0 0 600 600" xml:space="preserve">\n<desc>Created with Fabric.js ' + fabric.version + '</desc>\n<defs></defs>\n</svg>';
var CANVAS_SVG_VIEWBOX = '<?xml version="1.0" encoding="UTF-8" standalone="no" ?>\n<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">\n'+
var CANVAS_SVG_VIEWBOX = '<?xml version="1.0" encoding="UTF-8" standalone="no" ?>\n<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">\n' +
'<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="600" height="600" viewBox="100 100 300 300" xml:space="preserve">\n<desc>Created with Fabric.js ' + fabric.version + '</desc>\n<defs></defs>\n</svg>';
var PATH_JSON = '{"objects": [{"type": "path", "originX": "left", "originY": "top", "left": 268, "top": 266, "width": 51, "height": 49,'+
' "fill": "rgb(0,0,0)", "stroke": null, "strokeWidth": 1, "scaleX": 1, "scaleY": 1, '+
'"angle": 0, "flipX": false, "flipY": false, "opacity": 1, "path": [["M", 18.511, 13.99],'+
' ["c", 0, 0, -2.269, -4.487, -12.643, 4.411], ["c", 0, 0, 4.824, -14.161, 19.222, -9.059],'+
' ["l", 0.379, -2.1], ["c", -0.759, -0.405, -1.375, -1.139, -1.645, -2.117], ["c", -0.531, '+
'-1.864, 0.371, -3.854, 1.999, -4.453], ["c", 0.312, -0.118, 0.633, -0.169, 0.953, -0.169], '+
'["c", 1.299, 0, 2.514, 0.953, 2.936, 2.455], ["c", 0.522, 1.864, -0.372, 3.854, -1.999, '+
'4.453], ["c", -0.229, 0.084, -0.464, 0.127, -0.692, 0.152], ["l", -0.379, 2.37], ["c", '+
'1.146, 0.625, 2.024, 1.569, 2.674, 2.758], ["c", 3.213, 2.514, 8.561, 4.184, 11.774, -8.232],'+
' ["c", 0, 0, 0.86, 16.059, -12.424, 14.533], ["c", 0.008, 2.859, 0.615, 5.364, -0.076, 8.224],'+
' ["c", 8.679, 3.146, 15.376, 14.389, 17.897, 18.168], ["l", 2.497, -2.151], ["l", 1.206, 1.839],'+
' ["l", -3.889, 3.458], ["C", 46.286, 48.503, 31.036, 32.225, 22.72, 35.81], ["c", -1.307, 2.851,'+
' -3.56, 6.891, -7.481, 8.848], ["c", -4.689, 2.336, -9.084, -0.802, -11.277, -2.868], ["l",'+
' -1.948, 3.104], ["l", -1.628, -1.333], ["l", 3.138, -4.689], ["c", 0.025, 0, 9, 1.932, 9, 1.932], '+
'["c", 0.877, -9.979, 2.893, -12.905, 4.942, -15.621], ["C", 17.878, 21.775, 18.713, 17.397, 18.511, '+
var PATH_JSON = '{"objects": [{"type": "path", "originX": "left", "originY": "top", "left": 268, "top": 266, "width": 51, "height": 49,' +
' "fill": "rgb(0,0,0)", "stroke": null, "strokeWidth": 1, "scaleX": 1, "scaleY": 1, ' +
'"angle": 0, "flipX": false, "flipY": false, "opacity": 1, "path": [["M", 18.511, 13.99],' +
' ["c", 0, 0, -2.269, -4.487, -12.643, 4.411], ["c", 0, 0, 4.824, -14.161, 19.222, -9.059],' +
' ["l", 0.379, -2.1], ["c", -0.759, -0.405, -1.375, -1.139, -1.645, -2.117], ["c", -0.531, ' +
'-1.864, 0.371, -3.854, 1.999, -4.453], ["c", 0.312, -0.118, 0.633, -0.169, 0.953, -0.169], ' +
'["c", 1.299, 0, 2.514, 0.953, 2.936, 2.455], ["c", 0.522, 1.864, -0.372, 3.854, -1.999, ' +
'4.453], ["c", -0.229, 0.084, -0.464, 0.127, -0.692, 0.152], ["l", -0.379, 2.37], ["c", ' +
'1.146, 0.625, 2.024, 1.569, 2.674, 2.758], ["c", 3.213, 2.514, 8.561, 4.184, 11.774, -8.232],' +
' ["c", 0, 0, 0.86, 16.059, -12.424, 14.533], ["c", 0.008, 2.859, 0.615, 5.364, -0.076, 8.224],' +
' ["c", 8.679, 3.146, 15.376, 14.389, 17.897, 18.168], ["l", 2.497, -2.151], ["l", 1.206, 1.839],' +
' ["l", -3.889, 3.458], ["C", 46.286, 48.503, 31.036, 32.225, 22.72, 35.81], ["c", -1.307, 2.851,' +
' -3.56, 6.891, -7.481, 8.848], ["c", -4.689, 2.336, -9.084, -0.802, -11.277, -2.868], ["l",' +
' -1.948, 3.104], ["l", -1.628, -1.333], ["l", 3.138, -4.689], ["c", 0.025, 0, 9, 1.932, 9, 1.932], ' +
'["c", 0.877, -9.979, 2.893, -12.905, 4.942, -15.621], ["C", 17.878, 21.775, 18.713, 17.397, 18.511, ' +
'13.99], ["z", null]]}], "background": "#ff5555", "overlay":"rgba(0,0,0,0.2)"}';
var PATH_DATALESS_JSON = '{"objects":[{"type":"path","originX":"left","originY":"top","left":100,"top":100,"width":200,"height":200,"fill":"rgb(0,0,0)",'+
'"stroke":null,"strokeWidth":1,"strokeDashArray":null,"strokeLineCap":"butt","strokeLineJoin":"miter","strokeMiterLimit":10,'+
'"scaleX":1,"scaleY":1,"angle":0,"flipX":false,"flipY":false,"opacity":1,'+
var PATH_DATALESS_JSON = '{"objects":[{"type":"path","originX":"left","originY":"top","left":100,"top":100,"width":200,"height":200,"fill":"rgb(0,0,0)",' +
'"stroke":null,"strokeWidth":1,"strokeDashArray":null,"strokeLineCap":"butt","strokeLineJoin":"miter","strokeMiterLimit":10,' +
'"scaleX":1,"scaleY":1,"angle":0,"flipX":false,"flipY":false,"opacity":1,' +
'"shadow":null,"visible":true,"clipTo":null,"backgroundColor":"","fillRule":"nonzero","globalCompositeOperation":"source-over","transformMatrix":null,"skewX":0,"skewY":0,"path":"http://example.com/","pathOffset":{"x":200,"y":200}}],"background":""}';
var RECT_JSON = '{"objects":[{"type":"rect","originX":"left","originY":"top","left":0,"top":0,"width":10,"height":10,"fill":"rgb(0,0,0)",'+
'"stroke":null,"strokeWidth":1,"strokeDashArray":null,"strokeLineCap":"butt","strokeLineJoin":"miter","strokeMiterLimit":10,'+
'"scaleX":1,"scaleY":1,"angle":0,"flipX":false,"flipY":false,"opacity":1,'+
var RECT_JSON = '{"objects":[{"type":"rect","originX":"left","originY":"top","left":0,"top":0,"width":10,"height":10,"fill":"rgb(0,0,0)",' +
'"stroke":null,"strokeWidth":1,"strokeDashArray":null,"strokeLineCap":"butt","strokeLineJoin":"miter","strokeMiterLimit":10,' +
'"scaleX":1,"scaleY":1,"angle":0,"flipX":false,"flipY":false,"opacity":1,' +
'"shadow":null,"visible":true,"clipTo":null,"backgroundColor":"","fillRule":"nonzero","globalCompositeOperation":"source-over","transformMatrix":null,"skewX":0,"skewY":0,"rx":0,"ry":0}],"background":"#ff5555","overlay":"rgba(0,0,0,0.2)"}';
var RECT_JSON_WITH_PADDING = '{"objects":[{"type":"rect","originX":"left","originY":"top","left":0,"top":0,"width":10,"height":20,"fill":"rgb(0,0,0)",'+
'"stroke":null,"strokeWidth":1,"strokeDashArray":null,"strokeLineCap":"butt","strokeLineJoin":"miter","strokeMiterLimit":10,'+
'"scaleX":1,"scaleY":1,"angle":0,"flipX":false,"flipY":false,"opacity":1,'+
var RECT_JSON_WITH_PADDING = '{"objects":[{"type":"rect","originX":"left","originY":"top","left":0,"top":0,"width":10,"height":20,"fill":"rgb(0,0,0)",' +
'"stroke":null,"strokeWidth":1,"strokeDashArray":null,"strokeLineCap":"butt","strokeLineJoin":"miter","strokeMiterLimit":10,' +
'"scaleX":1,"scaleY":1,"angle":0,"flipX":false,"flipY":false,"opacity":1,' +
'"shadow":null,"visible":true,"clipTo":null,"backgroundColor":"","fillRule":"nonzero","globalCompositeOperation":"source-over","transformMatrix":null,"skewX":0,"skewY":0,"padding":123,"foo":"bar","rx":0,"ry":0}],"background":""}';

@@ -46,3 +46,3 @@

var isAbsolute = /^https?:/.test(path);
if (isAbsolute) return path;
if (isAbsolute) { return path };
var imgEl = _createImageElement();

@@ -118,3 +118,3 @@ imgEl.src = path;

require('fs').readFile(src, function(err, imgData) {
if (err) throw err;
if (err) { throw err };
img.src = imgData;

@@ -176,2 +176,10 @@ img._src = src;

ok('clipTo' in canvas);
ok('includeDefaultValues' in canvas);
ok('stateful' in canvas);
ok('renderOnAddRemove' in canvas);
ok('controlsAboveOverlay' in canvas);
ok('allowTouchScrolling' in canvas);
ok('imageSmoothingEnabled' in canvas);
ok('backgroundVpt' in canvas);
ok('overlayVpt' in canvas);

@@ -182,3 +190,6 @@ equal(canvas.includeDefaultValues, true);

equal(canvas.controlsAboveOverlay, false);
equal(canvas.allowTouchScrolling, false);
equal(canvas.imageSmoothingEnabled, true);
equal(canvas.backgroundVpt, true);
equal(canvas.overlayVpt, true);

@@ -431,5 +442,13 @@ notStrictEqual(canvas.viewportTransform, canvas2.viewportTransform);

ok(typeof canvas.clear == 'function');
var bg = new fabric.Rect({ width: 10, height: 20 });
canvas.backgroundColor = '#FF0000';
canvas.overlayColor = '#FF0000';
canvas.backgroundImage = bg;
canvas.overlayImage = bg;
equal(canvas.clear(), canvas, 'should be chainable');
equal(canvas.getObjects().length, 0);
equal(canvas.getObjects().length, 0, 'clear remove all objects');
equal(canvas.backgroundColor, '', 'clear remove background color');
equal(canvas.overlayColor, '', 'clear remove overlay color');
equal(canvas.backgroundImage, null, 'clear remove bg image');
equal(canvas.overlayImage, null, 'clear remove overlay image');
});

@@ -445,6 +464,6 @@

if (!fabric.Canvas.supports('toDataURL')) {
window.alert("toDataURL is not supported by this environment. Some of the tests can not be run.");
window.alert('toDataURL is not supported by this environment. Some of the tests can not be run.');
}
else {
var rect = new fabric.Rect({width: 100, height: 100, fill:'red', top: 0, left: 0});
var rect = new fabric.Rect({width: 100, height: 100, fill: 'red', top: 0, left: 0});
canvas.add(rect);

@@ -463,3 +482,3 @@ var dataURL = canvas.toDataURL();

if (!fabric.Canvas.supports('toDataURL')) {
window.alert("toDataURL is not supported by this environment. Some of the tests can not be run.");
window.alert('toDataURL is not supported by this environment. Some of the tests can not be run.');
}

@@ -472,3 +491,3 @@ else {

// node-canvas does not support jpeg data urls
catch(err) {
catch (err) {
ok(true);

@@ -778,2 +797,13 @@ }

asyncTest('toJSON backgroundImage with custom props', function() {
createImageObject(function(image) {
canvas.backgroundImage = image;
image.custom = 'yes';
var json = canvas.toJSON(['custom']);
equal(json.backgroundImage.custom, 'yes');
canvas.backgroundImage = null;
start();
});
});
asyncTest('toJSON overlayImage', function() {

@@ -795,2 +825,13 @@ createImageObject(function(image) {

asyncTest('toJSON overlayImage with custom props', function() {
createImageObject(function(image) {
canvas.overlayImage = image;
image.custom = 'yes';
var json = canvas.toJSON(['custom']);
equal(json.overlayImage.custom, 'yes');
canvas.overlayImage = null;
start();
});
});
test('toDatalessJSON', function() {

@@ -943,3 +984,3 @@ var path = new fabric.Path('M 100 100 L 300 100 L 200 300 z', {

rect.padding = 123;
rect.foo = "bar";
rect.foo = 'bar';

@@ -1356,14 +1397,2 @@ canvas.add(rect);

test('getActiveObject', function() {
ok(typeof canvas.getActiveObject == 'function');
var activeObject = canvas.getActiveObject();
equal(activeObject, null, 'should return null');
});
test('getActiveGroup', function() {
ok(typeof canvas.getActiveGroup == 'function');
var activeGroup = canvas.getActiveGroup();
equal(activeGroup, null, 'should return null');
});
test('getContext', function() {

@@ -1370,0 +1399,0 @@ ok(typeof canvas.getContext == 'function');

@@ -179,3 +179,3 @@ (function() {

}
catch(err) {
catch (err) {
error = err;

@@ -191,3 +191,3 @@ }

}
catch(err) {
catch (err) {
error = err;

@@ -194,0 +194,0 @@ }

@@ -417,3 +417,3 @@ (function() {

equal(gradient.colorStops[1].color, 'rgb(255,255,255)');
deepEqual(gradient.gradientTransform, [ 3.321, -0.6998, 0.4077, 1.9347, -440.9168, -408.0598 ]);
deepEqual(gradient.gradientTransform, [3.321, -0.6998, 0.4077, 1.9347, -440.9168, -408.0598]);
});

@@ -420,0 +420,0 @@

@@ -16,3 +16,3 @@ (function() {

return new fabric.Group([ rect1, rect2 ], {strokeWidth: 0});
return new fabric.Group([rect1, rect2], {strokeWidth: 0});
}

@@ -24,3 +24,3 @@

return new fabric.Group([ rect1, rect2 ], {strokeWidth: 0});
return new fabric.Group([rect1, rect2], {strokeWidth: 0});
}

@@ -34,3 +34,3 @@

return new fabric.Group([ rect1, rect2, rect3, rect4 ]);
return new fabric.Group([rect1, rect2, rect3, rect4]);
}

@@ -63,3 +63,3 @@

var group = new fabric.Group([ rect1, rect2 ]);
var group = new fabric.Group([rect1, rect2]);

@@ -69,3 +69,3 @@ ok(typeof group.getObjects == 'function');

equal(group.getObjects().length, 2, 'should have 2 items');
deepEqual(group.getObjects(), [ rect1, rect2 ], 'should return deepEqual objects as those passed to constructor');
deepEqual(group.getObjects(), [rect1, rect2], 'should return deepEqual objects as those passed to constructor');
});

@@ -77,3 +77,3 @@

var group = new fabric.Group([ rect, circle ]);
var group = new fabric.Group([rect, circle]);

@@ -94,7 +94,7 @@ equal(group.size(), 2, 'should have length=2 initially');

equal(group.add(rect1), group, 'should be chainable');
strictEqual(group.item(group.size()-1), rect1, 'last object should be newly added one');
strictEqual(group.item(group.size() - 1), rect1, 'last object should be newly added one');
equal(group.getObjects().length, 3, 'there should be 3 objects');
group.add(rect2, rect3);
strictEqual(group.item(group.size()-1), rect3, 'last object should be last added one');
strictEqual(group.item(group.size() - 1), rect3, 'last object should be last added one');
equal(group.size(), 5, 'there should be 5 objects');

@@ -107,3 +107,3 @@ });

rect3 = new fabric.Rect(),
group = new fabric.Group([ rect1, rect2, rect3 ]);
group = new fabric.Group([rect1, rect2, rect3]);

@@ -157,3 +157,3 @@ ok(typeof group.remove == 'function');

notIncludedRect = new fabric.Rect(),
group = new fabric.Group([ rect1, rect2 ]);
group = new fabric.Group([rect1, rect2]);

@@ -215,18 +215,18 @@ ok(typeof group.contains == 'function');

test('toObject without default values', function() {
var group = makeGroupWith2Objects();
group.includeDefaultValues = false;
var clone = group.toObject();
test('toObject without default values', function() {
var group = makeGroupWith2Objects();
group.includeDefaultValues = false;
var clone = group.toObject();
var expectedObject = {
'type': 'group',
'left': 50,
'top': 100,
'width': 80,
'height': 60,
'objects': clone.objects
};
var expectedObject = {
'type': 'group',
'left': 50,
'top': 100,
'width': 80,
'height': 60,
'objects': clone.objects
};
deepEqual(clone, expectedObject);
});
deepEqual(clone, expectedObject);
});

@@ -334,3 +334,3 @@ test('render', function() {

var invokedObjects = [ ];
var invokedObjects = [];
group.forEachObject(function(groupObject){

@@ -377,3 +377,3 @@ groupObject.setCoords = function() {

var iteratedObjects = [ ];
var iteratedObjects = [];
group.forEachObject(function(groupObject) {

@@ -457,9 +457,9 @@ iteratedObjects.push(groupObject);

var textBg = new fabric.Rect({
fill : '#abc',
width : 100,
height : 100
fill: '#abc',
width: 100,
height: 100
});
var text = new fabric.Text('text');
var group = new fabric.Group([ textBg, text ]);
var group = new fabric.Group([textBg, text]);

@@ -533,3 +533,3 @@ canvas.add(group);

rect2 = new fabric.Rect({ top: 4, left: 4, width: 2, height: 2, strokeWidth: 0, fill: 'red', opacity: 1}),
group = new fabric.Group([ rect1, rect2 ], {opacity: 1, fill: 'blue', strokeWidth: 0}),
group = new fabric.Group([rect1, rect2], {opacity: 1, fill: 'blue', strokeWidth: 0}),
isTransparent = fabric.util.isTransparent,

@@ -536,0 +536,0 @@ ctx = canvas.contextContainer;

@@ -5,3 +5,3 @@ (function() {

var isAbsolute = /^https?:/.test(path);
if (isAbsolute) return path;
if (isAbsolute) { return path };
var imgEl = _createImageElement();

@@ -72,3 +72,3 @@ imgEl.src = path;

require('fs').readFile(src, function(err, imgData) {
if (err) throw err;
if (err) { throw err };
img.src = imgData;

@@ -692,3 +692,3 @@ callback && callback();

}
equal(JSON.stringify(object), '{"type":"Mask","mask":'+JSON.stringify(maskObj)+',"channel":0}');
equal(JSON.stringify(object), '{"type":"Mask","mask":' + JSON.stringify(maskObj) + ',"channel":0}');

@@ -714,3 +714,3 @@ start();

}
equal(JSON.stringify(json), '{"type":"Mask","mask":'+JSON.stringify(maskObj)+',"channel":0}');
equal(JSON.stringify(json), '{"type":"Mask","mask":' + JSON.stringify(maskObj) + ',"channel":0}');

@@ -717,0 +717,0 @@ start();

@@ -5,3 +5,3 @@ (function() {

var isAbsolute = /^https?:/.test(path);
if (isAbsolute) return path;
if (isAbsolute) { return path };
var imgEl = _createImageElement();

@@ -95,3 +95,3 @@ imgEl.src = path;

require('fs').readFile(src, function(err, imgData) {
if (err) throw err;
if (err) { throw err };
img.src = imgData;

@@ -335,3 +335,3 @@ img._src = src;

var IMAGE_DATA_URL = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA4AAAARCAYAAADtyJ2fAAAACXBIWXMAAAsSAAALEgHS3X78AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAVBJREFUeNqMU7tOBDEMtENuy614/QE/gZBOuvJK+Et6CiQ6JP6ExxWI7bhL1vgVExYKLPmsTTIzjieHd+MZZSBIAJwEyJU0EWaum+lNljRux3O6nl70Gx/GUwUeyYcDJWZNhMK1aEXYe95Mz4iP44kDTRUZSWSq1YEHri0/HZxXfGSFBN+qDEJTrNI+QXRBviZ7eWCQgjsg+IHiHYB30MhqUxwcmH1Arc2kFDwkBldeFGJLPqs/AbbF2dWgUym6Z2Tb6RVzYxG1wUnmaNcOonZiU0++l6C7FzoQY42g3+8jz+GZ+dWMr1rRH0OjAFhPO+VJFx/vWDqPmk8H97CGBUYUiqAGW0PVe1+aX8j2Ll0tgHtvLx6AK9Tu1ZTFTQ0ojChqGD4qkOzeAuzVfgzsaTym1ClS+IdwtQCFooQMBTumNun1H6Bfcc9/MUn4R3wJMAAZH6MmA4ht4gAAAABJRU5ErkJggg==";
var IMAGE_DATA_URL = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA4AAAARCAYAAADtyJ2fAAAACXBIWXMAAAsSAAALEgHS3X78AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAVBJREFUeNqMU7tOBDEMtENuy614/QE/gZBOuvJK+Et6CiQ6JP6ExxWI7bhL1vgVExYKLPmsTTIzjieHd+MZZSBIAJwEyJU0EWaum+lNljRux3O6nl70Gx/GUwUeyYcDJWZNhMK1aEXYe95Mz4iP44kDTRUZSWSq1YEHri0/HZxXfGSFBN+qDEJTrNI+QXRBviZ7eWCQgjsg+IHiHYB30MhqUxwcmH1Arc2kFDwkBldeFGJLPqs/AbbF2dWgUym6Z2Tb6RVzYxG1wUnmaNcOonZiU0++l6C7FzoQY42g3+8jz+GZ+dWMr1rRH0OjAFhPO+VJFx/vWDqPmk8H97CGBUYUiqAGW0PVe1+aX8j2Ll0tgHtvLx6AK9Tu1ZTFTQ0ojChqGD4qkOzeAuzVfgzsaTym1ClS+IdwtQCFooQMBTumNun1H6Bfcc9/MUn4R3wJMAAZH6MmA4ht4gAAAABJRU5ErkJggg==';

@@ -341,5 +341,5 @@ ok(typeof fabric.Image.fromElement == 'function', 'fromElement should exist');

var imageEl = makeImageElement({
width: "14",
height: "17",
"xlink:href": IMAGE_DATA_URL
width: '14',
height: '17',
'xlink:href': IMAGE_DATA_URL
});

@@ -346,0 +346,0 @@

@@ -106,3 +106,3 @@ (function(){

iText.selectionEnd = 31;
iText.moveCursorUp({ shiftKey: false});
iText.moveCursorUp({ shiftKey: false });
equal(selection, 1, 'should fire');

@@ -115,3 +115,3 @@ equal(iText.selectionStart, 9, 'should move to upper line');

iText.selectionEnd = 4;
iText.moveCursorDown({ shiftKey: false});
iText.moveCursorDown({ shiftKey: false });
equal(selection, 1, 'should fire');

@@ -124,3 +124,3 @@ equal(iText.selectionStart, 24, 'should move to down line');

iText.selectionEnd = 31;
iText.moveCursorLeft({ shiftKey: false});
iText.moveCursorLeft({ shiftKey: false });
equal(selection, 1, 'should fire');

@@ -127,0 +127,0 @@ equal(iText.selectionStart, 28, 'should move to selection Start');

@@ -154,2 +154,7 @@ (function() {

test('empty itext', function() {
var iText = new fabric.IText('');
equal(iText.width, iText.cursorWidth);
})
test('setSelectionEnd', function() {

@@ -758,6 +763,6 @@ var iText = new fabric.IText('test');

var svgString = canvas.toSVG(),
doc = parser.parseFromString(svgString, "image/svg+xml"),
doc = parser.parseFromString(svgString, 'image/svg+xml'),
style = doc.getElementsByTagName('style')[0].firstChild.data;
equal(style, '\n\t\t@font-face {\n\t\t\tfont-family: \'Plaster\';\n\t\t\tsrc: url(\'path-to-plaster-font-file\');\n\t\t}\n\t\t@font-face {\n\t\t\tfont-family: \'Engagement\';\n\t\t\tsrc: url(\'path-to-engagement-font-file\');\n\t\t}\n');
equal(style, '\n\t\t@font-face {\n\t\t\tfont-family: \'Plaster\';\n\t\t\tsrc: url(\'path-to-plaster-font-file\');\n\t\t}\n\t\t@font-face {\n\t\t\tfont-family: \'Engagement\';\n\t\t\tsrc: url(\'path-to-engagement-font-file\');\n\t\t}\n');
});
})();

@@ -140,3 +140,3 @@ (function(){

test('changing x/y coords should update width/height', function() {
var line = new fabric.Line([ 50, 50, 100, 100]);
var line = new fabric.Line([50, 50, 100, 100]);

@@ -200,3 +200,3 @@ equal(50, line.width);

givenLineArgs: {
points: [0+33, 0+44, 11+33, 22+44],
points: [0 + 33, 0 + 44, 11 + 33, 22 + 44],
options: {

@@ -227,3 +227,3 @@ originX: 'left',

givenLineArgs: {
points: [0+9.87, 0-4.32, 12.3+9.87, 34.5-4.32],
points: [0 + 9.87, 0 - 4.32, 12.3 + 9.87, 34.5 - 4.32],
options: {

@@ -254,3 +254,3 @@ originX: 'center',

givenLineArgs: {
points: [0-3.14, 0-1.41, 55-3.14, 18-1.41],
points: [0 - 3.14, 0 - 1.41, 55 - 3.14, 18 - 1.41],
options: {

@@ -339,3 +339,3 @@ originX: 'right',

givenLineArgs: {
points: [0+31, 15+26, 28+31, 0+26],
points: [0 + 31, 15 + 26, 28 + 31, 0 + 26],
options: {

@@ -463,9 +463,9 @@ originX: 'center',

givenOrigin: 'left',
givenPoints: [0+20, 0, 1+20, 0],
expectedLeft: 0+20,
givenPoints: [0 + 20, 0, 1 + 20, 0],
expectedLeft: 0 + 20,
},
{ description: 'includes negative offset for left origin',
givenOrigin: 'left',
givenPoints: [0-11, 0, 1-11, 0],
expectedLeft: 0-11,
givenPoints: [0 - 11, 0, 1 - 11, 0],
expectedLeft: 0 - 11,
},

@@ -484,3 +484,3 @@ { description: 'is half of x1 for center origin and x1 > x2',

givenOrigin: 'center',
givenPoints: [0+39, 0, 7+39, 0],
givenPoints: [0 + 39, 0, 7 + 39, 0],
expectedLeft: (0.5 * 7) + 39,

@@ -490,3 +490,3 @@ },

givenOrigin: 'center',
givenPoints: [4-13, 0, 0-13, 0],
givenPoints: [4 - 13, 0, 0 - 13, 0],
expectedLeft: (0.5 * 4) - 13,

@@ -506,3 +506,3 @@ },

givenOrigin: 'right',
givenPoints: [0+47, 0, 6+47, 0],
givenPoints: [0 + 47, 0, 6 + 47, 0],
expectedLeft: 6 + 47,

@@ -512,3 +512,3 @@ },

givenOrigin: 'right',
givenPoints: [9-17, 0, 0-17, 0],
givenPoints: [9 - 17, 0, 0 - 17, 0],
expectedLeft: 9 - 17,

@@ -542,9 +542,9 @@ },

givenOrigin: 'top',
givenPoints: [0, 0+20, 0, 1+20],
expectedTop: 0+20,
givenPoints: [0, 0 + 20, 0, 1 + 20],
expectedTop: 0 + 20,
},
{ description: 'includes negative offset for top origin',
givenOrigin: 'top',
givenPoints: [0, 0-11, 0, 1-11],
expectedTop: 0-11,
givenPoints: [0, 0 - 11, 0, 1 - 11],
expectedTop: 0 - 11,
},

@@ -563,3 +563,3 @@ { description: 'is half of y1 for center origin and y1 > y2',

givenOrigin: 'center',
givenPoints: [0, 0+39, 0, 7+39],
givenPoints: [0, 0 + 39, 0, 7 + 39],
expectedTop: (0.5 * 7) + 39,

@@ -569,3 +569,3 @@ },

givenOrigin: 'center',
givenPoints: [0, 4-13, 0, 0-13],
givenPoints: [0, 4 - 13, 0, 0 - 13],
expectedTop: (0.5 * 4) - 13,

@@ -585,3 +585,3 @@ },

givenOrigin: 'bottom',
givenPoints: [0, 0+47, 0, 6+47],
givenPoints: [0, 0 + 47, 0, 6 + 47],
expectedTop: 6 + 47,

@@ -591,3 +591,3 @@ },

givenOrigin: 'bottom',
givenPoints: [0, 9-17, 0, 0-17],
givenPoints: [0, 9 - 17, 0, 0 - 17],
expectedTop: 9 - 17,

@@ -594,0 +594,0 @@ },

@@ -96,3 +96,2 @@ (function() {

test('translateToOriginPoint', function(){

@@ -241,4 +240,3 @@ var rect = new fabric.Rect(rectOptions),

test('adjustPosition', function(){
var rect = new fabric.Rect(rectOptions),
p;
var rect = new fabric.Rect(rectOptions);

@@ -248,3 +246,3 @@ rect.strokeWidth = 0;

rect.originY = 'top';
p = rect.adjustPosition('left');
rect.adjustPosition('left');
deepEqual(rect.left, 35);

@@ -254,3 +252,3 @@ deepEqual(rect.top, 45);

p = rect.adjustPosition('center');
rect.adjustPosition('center');
deepEqual(rect.left, 55);

@@ -260,3 +258,3 @@ deepEqual(rect.top, 45);

p = rect.adjustPosition('right');
rect.adjustPosition('right');
deepEqual(rect.left, 75);

@@ -268,3 +266,3 @@ deepEqual(rect.top, 45);

rect.originY = 'center';
p = rect.adjustPosition('left');
rect.adjustPosition('left');
deepEqual(rect.left, 55);

@@ -274,3 +272,3 @@ deepEqual(rect.top, 45);

p = rect.adjustPosition('center');
rect.adjustPosition('center');
deepEqual(rect.left, 75);

@@ -280,3 +278,3 @@ deepEqual(rect.top, 45);

p = rect.adjustPosition('right');
rect.adjustPosition('right');
deepEqual(rect.left, 95);

@@ -288,3 +286,3 @@ deepEqual(rect.top, 45);

rect.originY = 'bottom';
p = rect.adjustPosition('left');
rect.adjustPosition('left');
deepEqual(rect.left, 55);

@@ -294,3 +292,3 @@ deepEqual(rect.top, 45);

p = rect.adjustPosition('center');
rect.adjustPosition('center');
deepEqual(rect.left, 75);

@@ -300,3 +298,3 @@ deepEqual(rect.top, 45);

p = rect.adjustPosition('right');
rect.adjustPosition('right');
deepEqual(rect.left, 95);

@@ -308,4 +306,3 @@ deepEqual(rect.top, 45);

test('adjustPositionRotated', function(){
var rect = new fabric.Rect(rectOptions),
p;
var rect = new fabric.Rect(rectOptions);

@@ -316,3 +313,3 @@ rect.angle = 35;

rect.originY = 'top';
p = rect.adjustPosition('left');
rect.adjustPosition('left');
deepEqual(rect.left, 35);

@@ -322,3 +319,3 @@ deepEqual(rect.top, 45);

p = rect.adjustPosition('center');
rect.adjustPosition('center');
deepEqual(rect.left, 51.383040885779835);

@@ -328,3 +325,3 @@ deepEqual(rect.top, 56.471528727020925);

p = rect.adjustPosition('right');
rect.adjustPosition('right');
deepEqual(rect.left, 67.76608177155967);

@@ -336,3 +333,3 @@ deepEqual(rect.top, 67.94305745404185);

rect.originY = 'center';
p = rect.adjustPosition('left');
rect.adjustPosition('left');
deepEqual(rect.left, 51.383040885779835);

@@ -342,3 +339,3 @@ deepEqual(rect.top, 56.471528727020925);

p = rect.adjustPosition('center');
rect.adjustPosition('center');
deepEqual(rect.left, 67.76608177155967);

@@ -348,3 +345,3 @@ deepEqual(rect.top, 67.94305745404185);

p = rect.adjustPosition('right');
rect.adjustPosition('right');
deepEqual(rect.left, 84.1491226573395);

@@ -356,3 +353,3 @@ deepEqual(rect.top, 79.41458618106277);

rect.originY = 'bottom';
p = rect.adjustPosition('left');
rect.adjustPosition('left');
deepEqual(rect.left, 51.383040885779835);

@@ -362,3 +359,3 @@ deepEqual(rect.top, 56.47152872702093);

p = rect.adjustPosition('center');
rect.adjustPosition('center');
deepEqual(rect.left, 67.76608177155967);

@@ -368,3 +365,3 @@ deepEqual(rect.top, 67.94305745404185);

p = rect.adjustPosition('right');
rect.adjustPosition('right');
deepEqual(rect.left, 84.1491226573395);

@@ -446,3 +443,2 @@ deepEqual(rect.top, 79.41458618106277);

test('translateToOriginPoint with numeric origins', function(){

@@ -591,4 +587,3 @@ var rect = new fabric.Rect(rectOptions),

test('adjustPosition with numeric origins', function(){
var rect = new fabric.Rect(rectOptions),
p;
var rect = new fabric.Rect(rectOptions);

@@ -598,3 +593,3 @@ rect.strokeWidth = 0;

rect.originY = 'top';
p = rect.adjustPosition(0);
rect.adjustPosition(0);
deepEqual(rect.left, 35);

@@ -604,3 +599,3 @@ deepEqual(rect.top, 45);

p = rect.adjustPosition(0.5);
rect.adjustPosition(0.5);
deepEqual(rect.left, 55);

@@ -610,3 +605,3 @@ deepEqual(rect.top, 45);

p = rect.adjustPosition(1);
rect.adjustPosition(1);
deepEqual(rect.left, 75);

@@ -618,3 +613,3 @@ deepEqual(rect.top, 45);

rect.originY = 0.5;
p = rect.adjustPosition(0);
rect.adjustPosition(0);
deepEqual(rect.left, 55);

@@ -624,3 +619,3 @@ deepEqual(rect.top, 45);

p = rect.adjustPosition(0.5);
rect.adjustPosition(0.5);
deepEqual(rect.left, 75);

@@ -630,3 +625,3 @@ deepEqual(rect.top, 45);

p = rect.adjustPosition(1);
rect.adjustPosition(1);
deepEqual(rect.left, 95);

@@ -638,3 +633,3 @@ deepEqual(rect.top, 45);

rect.originY = 1;
p = rect.adjustPosition(0);
rect.adjustPosition(0);
deepEqual(rect.left, 55);

@@ -644,3 +639,3 @@ deepEqual(rect.top, 45);

p = rect.adjustPosition(0.5);
rect.adjustPosition(0.5);
deepEqual(rect.left, 75);

@@ -650,3 +645,3 @@ deepEqual(rect.top, 45);

p = rect.adjustPosition(1);
rect.adjustPosition(1);
deepEqual(rect.left, 95);

@@ -658,4 +653,3 @@ deepEqual(rect.top, 45);

test('adjustPositionRotated with numeric origins', function(){
var rect = new fabric.Rect(rectOptions),
p;
var rect = new fabric.Rect(rectOptions);

@@ -666,3 +660,3 @@ rect.angle = 35;

rect.originY = 0;
p = rect.adjustPosition(0);
rect.adjustPosition(0);
deepEqual(rect.left, 35);

@@ -672,3 +666,3 @@ deepEqual(rect.top, 45);

p = rect.adjustPosition(0.5);
rect.adjustPosition(0.5);
deepEqual(rect.left, 51.383040885779835);

@@ -678,3 +672,3 @@ deepEqual(rect.top, 56.471528727020925);

p = rect.adjustPosition(1);
rect.adjustPosition(1);
deepEqual(rect.left, 67.76608177155967);

@@ -686,3 +680,3 @@ deepEqual(rect.top, 67.94305745404185);

rect.originY = 0.5;
p = rect.adjustPosition(0);
rect.adjustPosition(0);
deepEqual(rect.left, 51.383040885779835);

@@ -692,3 +686,3 @@ deepEqual(rect.top, 56.471528727020925);

p = rect.adjustPosition(0.5);
rect.adjustPosition(0.5);
deepEqual(rect.left, 67.76608177155967);

@@ -698,3 +692,3 @@ deepEqual(rect.top, 67.94305745404185);

p = rect.adjustPosition(1);
rect.adjustPosition(1);
deepEqual(rect.left, 84.1491226573395);

@@ -706,3 +700,3 @@ deepEqual(rect.top, 79.41458618106277);

rect.originY = 1;
p = rect.adjustPosition(0);
rect.adjustPosition(0);
deepEqual(rect.left, 51.383040885779835);

@@ -712,3 +706,3 @@ deepEqual(rect.top, 56.47152872702093);

p = rect.adjustPosition(0.5);
rect.adjustPosition(0.5);
deepEqual(rect.left, 67.76608177155967);

@@ -718,3 +712,3 @@ deepEqual(rect.top, 67.94305745404185);

p = rect.adjustPosition(1);
rect.adjustPosition(1);
deepEqual(rect.left, 84.1491226573395);

@@ -721,0 +715,0 @@ deepEqual(rect.top, 79.41458618106277);

@@ -7,3 +7,5 @@ (function(){

var isAbsolute = /^https?:/.test(path);
if (isAbsolute) return path;
if (isAbsolute) {
return path;
}
var imgEl = _createImageElement();

@@ -16,4 +18,4 @@ imgEl.src = path;

var IMG_SRC = fabric.isLikelyNode ? (__dirname + '/../fixtures/test_image.gif') : getAbsolutePath('../fixtures/test_image.gif'),
IMG_WIDTH = 276,
var IMG_SRC = fabric.isLikelyNode ? (__dirname + '/../fixtures/test_image.gif') : getAbsolutePath('../fixtures/test_image.gif'),
IMG_WIDTH = 276,
IMG_HEIGHT = 110;

@@ -37,3 +39,5 @@

require('fs').readFile(src, function(err, imgData) {
if (err) throw err;
if (err) {
throw err;
};
img.src = imgData;

@@ -173,12 +177,12 @@ callback && callback();

test('toJSON', function() {
var emptyObjectJSON = '{"type":"object","originX":"left","originY":"top","left":0,"top":0,"width":0,"height":0,"fill":"rgb(0,0,0)",'+
'"stroke":null,"strokeWidth":1,"strokeDashArray":null,"strokeLineCap":"butt","strokeLineJoin":"miter","strokeMiterLimit":10,'+
'"scaleX":1,"scaleY":1,"angle":0,"flipX":false,"flipY":false,"opacity":1,'+
'"shadow":null,"visible":true,"clipTo":null,"backgroundColor":"","fillRule":"nonzero","globalCompositeOperation":"source-over",'+
var emptyObjectJSON = '{"type":"object","originX":"left","originY":"top","left":0,"top":0,"width":0,"height":0,"fill":"rgb(0,0,0)",' +
'"stroke":null,"strokeWidth":1,"strokeDashArray":null,"strokeLineCap":"butt","strokeLineJoin":"miter","strokeMiterLimit":10,' +
'"scaleX":1,"scaleY":1,"angle":0,"flipX":false,"flipY":false,"opacity":1,' +
'"shadow":null,"visible":true,"clipTo":null,"backgroundColor":"","fillRule":"nonzero","globalCompositeOperation":"source-over",' +
'"transformMatrix":null,"skewX":0,"skewY":0}';
var augmentedJSON = '{"type":"object","originX":"left","originY":"top","left":0,"top":0,"width":122,"height":0,"fill":"rgb(0,0,0)",'+
'"stroke":null,"strokeWidth":1,"strokeDashArray":[5,2],"strokeLineCap":"round","strokeLineJoin":"bevil","strokeMiterLimit":5,'+
'"scaleX":1.3,"scaleY":1,"angle":0,"flipX":false,"flipY":true,"opacity":0.88,'+
'"shadow":null,"visible":true,"clipTo":null,"backgroundColor":"","fillRule":"nonzero","globalCompositeOperation":"source-over",'+
var augmentedJSON = '{"type":"object","originX":"left","originY":"top","left":0,"top":0,"width":122,"height":0,"fill":"rgb(0,0,0)",' +
'"stroke":null,"strokeWidth":1,"strokeDashArray":[5,2],"strokeLineCap":"round","strokeLineJoin":"bevil","strokeMiterLimit":5,' +
'"scaleX":1.3,"scaleY":1,"angle":0,"flipX":false,"flipY":true,"opacity":0.88,' +
'"shadow":null,"visible":true,"clipTo":null,"backgroundColor":"","fillRule":"nonzero","globalCompositeOperation":"source-over",' +
'"transformMatrix":null,"skewX":0,"skewY":0}';

@@ -315,3 +319,3 @@

height: 40,
strokeDashArray: [ 5, 2 ],
strokeDashArray: [5, 2],
strokeLineCap: 'round',

@@ -402,3 +406,3 @@ strokeLineJoin: 'bevil',

test('getBoundingRectWithStroke', function() {
test('getBoundingRectWithStroke', function() {
var cObj = new fabric.Object(),

@@ -481,3 +485,3 @@ boundingRect;

equal(cObj.getWidth(), 100);
equal(cObj.get('scaleX'), 100/560);
equal(cObj.get('scaleX'), 100 / 560);
});

@@ -490,3 +494,3 @@

equal(cObj.getHeight(), 100);
equal(cObj.get('scaleY'), 100/560);
equal(cObj.get('scaleY'), 100 / 560);
});

@@ -538,3 +542,3 @@

if (!canvas.getContext && typeof G_vmlCanvasManager != 'undefined') {
G_vmlCanvasManager.initElement(canvas);
G_vmlCanvasManager.initElement(canvas);
}

@@ -553,3 +557,3 @@

if (!canvas.getContext && typeof G_vmlCanvasManager != 'undefined') {
G_vmlCanvasManager.initElement(canvas);
G_vmlCanvasManager.initElement(canvas);
}

@@ -656,3 +660,3 @@ var dummyContext = canvas.getContext('2d');

}
catch(err) {
catch (err) {
fabric.log('jpeg toDataURL not supported');

@@ -663,3 +667,3 @@ }

test('toDataURL & reference to canvas', function() {
test('toDataURL & reference to canvas', function() {
// var data =

@@ -675,40 +679,18 @@ // 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGQA'+

var cObj = new fabric.Rect({
width: 100, height: 100, fill: 'red'
});
canvas.add(cObj);
var cObj = new fabric.Rect({
width: 100, height: 100, fill: 'red'
});
canvas.add(cObj);
if (!fabric.Canvas.supports('toDataURL')) {
window.alert('toDataURL is not supported by this environment. Some of the tests can not be run.');
}
else {
var objCanvas = cObj.canvas;
cObj.toDataURL();
if (!fabric.Canvas.supports('toDataURL')) {
window.alert('toDataURL is not supported by this environment. Some of the tests can not be run.');
}
else {
var objCanvas = cObj.canvas;
cObj.toDataURL();
equal(objCanvas, cObj.canvas);
}
});
test('hasStateChanged', function() {
var cObj = new fabric.Object();
ok(typeof cObj.hasStateChanged == 'function');
cObj.setupState();
ok(!cObj.hasStateChanged());
cObj.saveState();
cObj.set('left', 123).set('top', 456);
ok(cObj.hasStateChanged());
equal(objCanvas, cObj.canvas);
}
});
test('saveState', function() {
var cObj = new fabric.Object();
ok(typeof cObj.saveState == 'function');
cObj.setupState();
equal(cObj.saveState(), cObj, 'chainable');
cObj.set('left', 123).set('top', 456);
cObj.saveState();
cObj.set('left', 223).set('top', 556);
equal(cObj.originalState.left, 123);
equal(cObj.originalState.top, 456);
});
test('intersectsWithRectangle', function() {

@@ -731,13 +713,18 @@ var cObj = new fabric.Object({ left: 50, top: 50, width: 100, height: 100 });

cObj.setCoords();
ok(typeof cObj.intersectsWithObject == 'function');
ok(typeof cObj.intersectsWithObject == 'function', 'has intersectsWithObject method');
var cObj2 = new fabric.Object({ left: -150, top: -150, width: 200, height: 200 });
cObj2.setCoords();
ok(cObj.intersectsWithObject(cObj2));
ok(cObj2.intersectsWithObject(cObj));
ok(cObj.intersectsWithObject(cObj2), 'cobj2 does intersect with cobj');
ok(cObj2.intersectsWithObject(cObj), 'cobj2 does intersect with cobj');
var cObj3 = new fabric.Object({ left: 392.5, top: 339.5, width: 13, height: 33 });
cObj3.setCoords();
ok(!cObj.intersectsWithObject(cObj3));
ok(!cObj3.intersectsWithObject(cObj));
ok(!cObj.intersectsWithObject(cObj3), 'cobj3 does not intersect with cobj (external)');
ok(!cObj3.intersectsWithObject(cObj), 'cobj3 does not intersect with cobj (external)');
var cObj4 = new fabric.Object({ left: 0, top: 0, width: 200, height: 200 });
cObj4.setCoords();
ok(cObj4.intersectsWithObject(cObj), 'overlapping objects are considered intersecting');
ok(cObj.intersectsWithObject(cObj4), 'overlapping objects are considered intersecting');
});

@@ -1342,27 +1329,42 @@

// object and object1 intersects
equal(object.intersectsWithObject(object1), true);
// object2 is contained in object (no intersection)
equal(object.intersectsWithObject(object2), false);
// object3 is outside of object (no intersection)
equal(object.intersectsWithObject(object3), false);
equal(object.intersectsWithObject(object1), true, 'object and object1 intersects');
equal(object.intersectsWithObject(object2), true, 'object2 is contained in object');
equal(object.intersectsWithObject(object3), false, 'object3 is outside of object (no intersection)');
});
test('isContainedWithinObject', function() {
var object = new fabric.Object({ left: 20, top: 30, width: 40, height: 50, angle: 230 }),
object1 = new fabric.Object({ left: 25, top: 35, width: 20, height: 20, angle: 50 }),
object2 = new fabric.Object({ left: 20, top: 30, width: 60, height: 30, angle: 10 }),
object3 = new fabric.Object({ left: 50, top: 50, width: 20, height: 20, angle: 0 });
var object = new fabric.Object({ left: 0, top: 0, width: 40, height: 40, angle: 0 }),
object1 = new fabric.Object({ left: 1, top: 1, width: 38, height: 38, angle: 0 }),
object2 = new fabric.Object({ left: 20, top: 20, width: 40, height: 40, angle: 0 }),
object3 = new fabric.Object({ left: 50, top: 50, width: 40, height: 40, angle: 0 });
object.set({ originX: 'center', originY: 'center' }).setCoords();
object1.set({ originX: 'center', originY: 'center' }).setCoords();
object2.set({ originX: 'center', originY: 'center' }).setCoords();
object3.set({ originX: 'center', originY: 'center' }).setCoords();
object.setCoords();
object1.setCoords();
object2.setCoords();
object3.setCoords();
// object1 is fully contained within object
equal(object1.isContainedWithinObject(object), true);
// object2 intersects object (not fully contained)
equal(object2.isContainedWithinObject(object), false);
// object3 is outside of object (not fully contained)
equal(object3.isContainedWithinObject(object), false);
equal(object1.isContainedWithinObject(object), true, 'object1 is fully contained within object');
equal(object2.isContainedWithinObject(object), false, 'object2 intersects object (not fully contained)');
equal(object3.isContainedWithinObject(object), false, 'object3 is outside of object (not fully contained)');
object1.angle = 45;
object1.setCoords();
equal(object1.isContainedWithinObject(object), false, 'object1 rotated is not contained within object');
var rect1 = new fabric.Rect({
width: 50,
height: 50,
left: 50,
top: 50
});
var rect2 = new fabric.Rect({
width: 100,
height: 100,
left: 100,
top: 0,
angle: 45,
});
rect1.setCoords();
rect2.setCoords();
equal(rect1.isContainedWithinObject(rect2), false, 'rect1 rotated is not contained within rect2');
});

@@ -1471,3 +1473,3 @@

test('getObjectScale', function() {
var object = new fabric.Object({ scaleX: 3, scaleY : 2});
var object = new fabric.Object({ scaleX: 3, scaleY: 2});
var objectScale = object.getObjectScaling();

@@ -1478,3 +1480,3 @@ deepEqual(objectScale, {scaleX: object.scaleX, scaleY: object.scaleY});

test('getObjectScale in group', function() {
var object = new fabric.Object({ scaleX: 3, scaleY : 2});
var object = new fabric.Object({ scaleX: 3, scaleY: 2});
var group = new fabric.Group();

@@ -1496,3 +1498,3 @@ group.scaleX = 2;

var context = canvas.contextContainer;
var object = new fabric.Object({ scaleX: 1, scaleY : 1});
var object = new fabric.Object({ scaleX: 1, scaleY: 1});
var group = new fabric.Group();

@@ -1499,0 +1501,0 @@ group.scaleX = 2;

@@ -215,3 +215,3 @@ QUnit.module('fabric.Observable');

equal(event3Fired, 0, 'Event 3 should not be fired yet');
equal(event4Fired, 0, 'Event 4 should not be fired yet');
equal(event4Fired, 0, 'Event 4 should not be fired yet');
foo.trigger('bar:baz');

@@ -218,0 +218,0 @@ equal(foo.__eventListeners['bar:baz'].length, 3, 'There should be 3 handlers registered now');

@@ -97,7 +97,7 @@ (function(){

grandParent.setAttribute('width', '600');
grandParent.setAttribute('height', '600');
grandParent.setAttribute('height', '600');
deepEqual(fabric.parseAttributes(element, 'x y width height'.split(' ')),
{ left: 100, top: 200, width: 600, height: 600 });
});
});

@@ -126,3 +126,3 @@ asyncTest('parseElements', function() {

}
catch(err) {
catch (err) {
error = err;

@@ -536,3 +536,3 @@ }

'polygon.cls': {
'fill' : '',
'fill': '',
'stroke': '#0000FF'

@@ -547,3 +547,3 @@ }

expectedStyle = {
'fill' : '',
'fill': '',
'stroke': '#0000FF'

@@ -556,3 +556,3 @@ };

var style = fabric.parseAttributes(elPolygon, [ ]);
var style = fabric.parseAttributes(elPolygon, []);
deepEqual(style, expectedStyle);

@@ -559,0 +559,0 @@

@@ -68,4 +68,4 @@ (function(){

var objects = [ ],
paths = ["M 100 100 L 300 100 L 200 300 z", "M 200 200 L 100 200 L 400 50 z"],
var objects = [],
paths = ['M 100 100 L 300 100 L 200 300 z', 'M 200 200 L 100 200 L 400 50 z'],
numLoadedObjects = 0,

@@ -119,7 +119,7 @@ numTotalObjects = paths.length;

test('parsingDmensionsWithTransformMatrix', function() {
var pathA = new fabric.Path("M 100 100 L 300 100 L 200 300 z", {transformMatrix: [2, 0, 0, 2, 0, 0]}),
pathB = new fabric.Path("M 200 200 L 100 200 L 400 50 z", {transformMatrix: [3, 0, 0, 3, 0, 0]}),
pg = new fabric.PathGroup([pathA, pathB], {toBeParsed: true});
equal(pg.width, 1203);
equal(pg.height, 603);
var pathA = new fabric.Path('M 100 100 L 300 100 L 200 300 z', {transformMatrix: [2, 0, 0, 2, 0, 0]}),
pathB = new fabric.Path('M 200 200 L 100 200 L 400 50 z', {transformMatrix: [3, 0, 0, 3, 0, 0]}),
pg = new fabric.PathGroup([pathA, pathB], {toBeParsed: true});
equal(pg.width, 1203);
equal(pg.height, 603);
});

@@ -126,0 +126,0 @@

@@ -54,3 +54,3 @@ (function() {

function makePathObject(callback) {
getPathObject("M 100 100 L 300 100 L 200 300 z", callback);
getPathObject('M 100 100 L 300 100 L 200 300 z', callback);
}

@@ -73,3 +73,3 @@

}
catch(err) {
catch (err) {
error = err;

@@ -194,3 +194,3 @@ }

path.get('transformMatrix'),
[ Math.cos(ANGLE), Math.sin(ANGLE), -Math.sin(ANGLE), Math.cos(ANGLE), 0, 0 ]
[Math.cos(ANGLE), Math.sin(ANGLE), -Math.sin(ANGLE), Math.cos(ANGLE), 0, 0]
);

@@ -197,0 +197,0 @@ start();

@@ -12,3 +12,3 @@ (function() {

require('fs').readFile(src, function(err, imgData) {
if (err) throw err;
if (err) { throw err };
img.src = imgData;

@@ -68,7 +68,7 @@ img._src = src;

var patternWithGetSource = new fabric.Pattern({
source: function() {return fabric.document.createElement("canvas")}
source: function() {return fabric.document.createElement('canvas')}
});
var object2 = patternWithGetSource.toObject();
equal(object2.source, 'function () {return fabric.document.createElement("canvas")}');
equal(object2.source, 'function () {return fabric.document.createElement(\'canvas\')}');
equal(object2.repeat, 'repeat');

@@ -75,0 +75,0 @@ });

@@ -62,3 +62,3 @@ (function() {

equal(polygon.type, 'polygon');
deepEqual(polygon.get('points'), [ { x: 10, y: 12 }, { x: 20, y: 22 } ]);
deepEqual(polygon.get('points'), [{ x: 10, y: 12 }, { x: 20, y: 22 }]);
});

@@ -114,3 +114,3 @@

fabric.util.object.clone(REFERENCE_OBJECT), {
points: [ { x: 10, y: 12 }, { x: 20, y: 22 } ]
points: [{ x: 10, y: 12 }, { x: 20, y: 22 }]
});

@@ -154,6 +154,6 @@

'left': 10,
'transformMatrix': [ 2, 0, 0, 2, -10, -20 ]
'transformMatrix': [2, 0, 0, 2, -10, -20]
}));
deepEqual(polygonWithAttrs.get('transformMatrix'), [ 2, 0, 0, 2, -10, -20 ]);
deepEqual(polygonWithAttrs.get('transformMatrix'), [2, 0, 0, 2, -10, -20]);

@@ -160,0 +160,0 @@ equal(fabric.Polygon.fromElement(), null);

@@ -62,3 +62,3 @@ (function() {

equal(polyline.type, 'polyline');
deepEqual(polyline.get('points'), [ { x: 10, y: 12 }, { x: 20, y: 22 } ]);
deepEqual(polyline.get('points'), [{ x: 10, y: 12 }, { x: 20, y: 22 }]);
});

@@ -141,9 +141,9 @@

'top': 10,
'transformMatrix' : [ 2, 0, 0, 2, -10, -20 ]
'transformMatrix': [2, 0, 0, 2, -10, -20]
}));
deepEqual(polylineWithAttrs.get('transformMatrix'), [ 2, 0, 0, 2, -10, -20 ]);
deepEqual(polylineWithAttrs.get('transformMatrix'), [2, 0, 0, 2, -10, -20]);
equal(fabric.Polyline.fromElement(), null);
equal(fabric.Polyline.fromElement(), null);
});
})();

@@ -72,4 +72,4 @@ (function() {

var expectedObject = fabric.util.object.extend({ }, REFERENCE_RECT);
expectedObject.fill = {"type":"linear","coords":{"x1":0,"y1":0,"x2":200,"y2":0},"colorStops":[{"offset":"0","color":"rgb(255,0,0)","opacity":1},{"offset":"1","color":"rgb(0,0,255)","opacity":1}],"offsetX":0,"offsetY":0};
expectedObject.stroke = {"type":"linear","coords":{"x1":0,"y1":0,"x2":200,"y2":0},"colorStops":[{"offset":"0","color":"rgb(255,0,0)","opacity":1},{"offset":"1","color":"rgb(0,0,255)","opacity":1}],"offsetX":0,"offsetY":0};
expectedObject.fill = {'type': 'linear','coords': {'x1': 0,'y1': 0,'x2': 200,'y2': 0},'colorStops': [{'offset': '0','color': 'rgb(255,0,0)','opacity': 1},{'offset': '1','color': 'rgb(0,0,255)','opacity': 1}],'offsetX': 0,'offsetY': 0};
expectedObject.stroke = {'type': 'linear','coords': {'x1': 0,'y1': 0,'x2': 200,'y2': 0},'colorStops': [{'offset': '0','color': 'rgb(255,0,0)','opacity': 1},{'offset': '1','color': 'rgb(0,0,255)','opacity': 1}],'offsetX': 0,'offsetY': 0};
rect = fabric.Rect.fromObject(expectedObject);

@@ -76,0 +76,0 @@ ok(rect.fill instanceof fabric.Gradient);

@@ -184,3 +184,3 @@ (function() {

});
test('toSVG with rotated object', function() {

@@ -195,3 +195,3 @@ // reset uid

});
test('toSVG with rotated flipped object', function() {

@@ -198,0 +198,0 @@ // reset uid

@@ -83,3 +83,3 @@ (function() {

else {
equal(fontDecl, ' normal 40px "Times New Roman"');
equal(fontDecl, ' normal 40px Times New Roman');
}

@@ -274,2 +274,7 @@

test('dimensions without text', function() {
var text = new fabric.Text('');
equal(text.width, 2);
});
test('setting fontFamily', function() {

@@ -276,0 +281,0 @@ var text = new fabric.Text('x');

@@ -15,3 +15,3 @@ (function() {

var isAbsolute = /^https?:/.test(path);
if (isAbsolute) return path;
if (isAbsolute) { return path };
var imgEl = _createImageElement();

@@ -25,3 +25,3 @@ imgEl.src = path;

var IMG_URL = fabric.isLikelyNode
? require("path").join(__dirname, '../fixtures/', 'very_large_image.jpg')
? require('path').join(__dirname, '../fixtures/', 'very_large_image.jpg')
: getAbsolutePath('../fixtures/very_large_image.jpg');

@@ -379,3 +379,3 @@

test('fabric.loadSVGFromURL', function() {
equal("function", typeof fabric.loadSVGFromURL);
equal('function', typeof fabric.loadSVGFromURL);
});

@@ -391,5 +391,5 @@

asyncTest('fabric.loadSVGFromString', function() {
equal("function", typeof fabric.loadSVGFromString);
equal('function', typeof fabric.loadSVGFromString);
var loadedObjects = [ ];
var loadedObjects = [];
fabric.loadSVGFromString(SVG_DOC_AS_STRING, function(objects) {

@@ -407,3 +407,3 @@ loadedObjects = objects;

asyncTest('fabric.loadSVGFromString with surrounding whitespace', function() {
var loadedObjects = [ ];
var loadedObjects = [];
fabric.loadSVGFromString(' \n\n ' + SVG_DOC_AS_STRING + ' ', function(objects) {

@@ -544,8 +544,8 @@ loadedObjects = objects;

equal(2, array.indexOf(3, -47), "large negative value for fromIndex");
equal(2, array.indexOf(3, -47), 'large negative value for fromIndex');
equal(10, array.indexOf(3, 4));
equal(10, array.indexOf(3, -5));
equal(2, array.indexOf(3, {}), "nonsensical value for fromIndex");
equal(2, array.indexOf(3, ""), "nonsensical value for fromIndex");
equal(-1, array.indexOf(3, 41), "fromIndex value larger than the length of the array");
equal(2, array.indexOf(3, {}), 'nonsensical value for fromIndex');
equal(2, array.indexOf(3, ''), 'nonsensical value for fromIndex');
equal(-1, array.indexOf(3, 41), 'fromIndex value larger than the length of the array');
});

@@ -557,3 +557,3 @@

var arr = [1,2,3];
var result = [ ];
var result = [];

@@ -657,3 +657,3 @@ arr.forEach(function(val, index, arr) {

deepEqual(['1!', '2!', '3!', '4!', '5!'],
arr.reduce(function(memo, val) { memo.push(val + '!'); return memo }, [ ]));
arr.reduce(function(memo, val) { memo.push(val + '!'); return memo }, []));

@@ -760,3 +760,3 @@ arr = 'foobar'.split('');

deepEqual(['obj1', 'obj2', 'obj3'],
fabric.util.array.invoke([ obj1, obj2, obj3 ], 'toString'));
fabric.util.array.invoke([obj1, obj2, obj3], 'toString'));

@@ -782,3 +782,3 @@ deepEqual(['f', 'b', 'b'],

equal(obj1, fabric.util.array.min([ obj1, obj3, obj2 ]));
equal(obj1, fabric.util.array.min([obj1, obj3, obj2]));
});

@@ -798,3 +798,3 @@

equal(obj3, fabric.util.array.max([ obj1, obj3, obj2 ]));
equal(obj3, fabric.util.array.max([obj1, obj3, obj2]));
});

@@ -806,7 +806,7 @@

var source = {
foo: 'bar',
baz: 123,
qux: function() { }
},
destination = { };
foo: 'bar',
baz: 123,
qux: function() { }
},
destination = { };

@@ -858,3 +858,3 @@ fabric.util.populateWithProperties(source, destination);

ok(typeof fabric.util.clearFabricFontCache == 'function');
fabric.charWidthsCache = { arial : { some: 'cache'}, helvetica : { some: 'cache'} };
fabric.charWidthsCache = { arial: { some: 'cache'}, helvetica: { some: 'cache'} };
fabric.util.clearFabricFontCache('arial');

@@ -870,11 +870,11 @@ equal(fabric.charWidthsCache.arial, undefined, 'arial cache is deleted');

var parsed;
parsed = fabric.util.parsePreserveAspectRatioAttribute("none");
parsed = fabric.util.parsePreserveAspectRatioAttribute('none');
equal(parsed.meetOrSlice, 'meet');
equal(parsed.alignX, 'none');
equal(parsed.alignY, 'none');
parsed = fabric.util.parsePreserveAspectRatioAttribute("none slice");
parsed = fabric.util.parsePreserveAspectRatioAttribute('none slice');
equal(parsed.meetOrSlice, 'slice');
equal(parsed.alignX, 'none');
equal(parsed.alignY, 'none');
parsed = fabric.util.parsePreserveAspectRatioAttribute("XmidYmax meet");
parsed = fabric.util.parsePreserveAspectRatioAttribute('XmidYmax meet');
equal(parsed.meetOrSlice, 'meet');

@@ -903,3 +903,3 @@ equal(parsed.alignX, 'mid');

var rect = new fabric.Rect({
top:1,
top: 1,
width: 100,

@@ -911,3 +911,3 @@ height: 100,

flipX: true,
flipY : true,
flipY: true,
skewX: 30,

@@ -914,0 +914,0 @@ skewY: 30

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc