2013-01-28 21:03:27 -05:00
|
|
|
/*
|
|
|
|
* Paper.js - The Swiss Army Knife of Vector Graphics Scripting.
|
|
|
|
* http://paperjs.org/
|
|
|
|
*
|
2014-01-03 19:47:16 -05:00
|
|
|
* Copyright (c) 2011 - 2014, Juerg Lehni & Jonathan Puckey
|
|
|
|
* http://scratchdisk.com/ & http://jonathanpuckey.com/
|
2013-01-28 21:03:27 -05:00
|
|
|
*
|
|
|
|
* Distributed under the MIT license. See LICENSE file for details.
|
|
|
|
*
|
|
|
|
* All rights reserved.
|
|
|
|
*/
|
|
|
|
|
2013-06-11 16:43:29 -04:00
|
|
|
// Register a jsDump parser for Base.
|
2013-06-11 16:38:08 -04:00
|
|
|
QUnit.jsDump.setParser('Base', function (obj, stack) {
|
2013-06-12 22:30:23 -04:00
|
|
|
// Just compare the string representation of classes inheriting from Base,
|
|
|
|
// since they hide the internal values.
|
2013-06-11 16:38:08 -04:00
|
|
|
return obj.toString();
|
|
|
|
});
|
|
|
|
|
2013-06-11 16:43:29 -04:00
|
|
|
// Override the default object parser to handle Base objects.
|
|
|
|
// We need to keep a reference to the previous implementation.
|
|
|
|
var objectParser = QUnit.jsDump.parsers.object;
|
|
|
|
|
2013-06-11 16:38:08 -04:00
|
|
|
QUnit.jsDump.setParser('object', function (obj, stack) {
|
|
|
|
return (obj instanceof Base
|
|
|
|
? QUnit.jsDump.parsers.Base
|
|
|
|
: objectParser).call(this, obj, stack);
|
|
|
|
});
|
|
|
|
|
2013-07-21 19:11:09 -04:00
|
|
|
function getFunctionBody(func) {
|
|
|
|
return func.toString().match(
|
|
|
|
/^\s*function[^\{]*\{([\s\S]*)\}\s*$/)[1]
|
|
|
|
.replace(/ /g, '')
|
|
|
|
.replace(/^\s+|\s+$/g, '');
|
|
|
|
}
|
|
|
|
|
2011-05-14 13:59:04 -04:00
|
|
|
// Override equals to convert functions to message and execute them as tests()
|
2013-02-08 22:37:58 -05:00
|
|
|
function equals(actual, expected, message, tolerance) {
|
2011-05-07 12:25:34 -04:00
|
|
|
if (typeof actual === 'function') {
|
|
|
|
if (!message) {
|
2013-07-21 19:11:09 -04:00
|
|
|
message = getFunctionBody(actual);
|
2011-05-07 12:46:06 -04:00
|
|
|
if (/^return /.test(message)) {
|
|
|
|
message = message
|
|
|
|
.replace(/^return /, '')
|
|
|
|
.replace(/;$/, '');
|
|
|
|
}
|
2011-05-07 12:25:34 -04:00
|
|
|
}
|
|
|
|
actual = actual();
|
|
|
|
}
|
2013-02-08 22:40:36 -05:00
|
|
|
// See if we need to compare with a tolerance, and if so, assume a number.
|
2013-02-08 22:37:58 -05:00
|
|
|
if (tolerance !== undefined) {
|
|
|
|
var ok = Math.abs(actual - expected) <= tolerance;
|
|
|
|
return QUnit.push(ok, ok ? expected : actual, expected, message);
|
2013-06-12 17:56:36 -04:00
|
|
|
} else if (actual && actual.equals) {
|
|
|
|
// Support calling of #equals() on the actual or expected value, and
|
|
|
|
// automatically convert displayed values to strings.
|
|
|
|
return QUnit.push(actual.equals(expected), actual, expected, message);
|
2013-02-08 22:37:58 -05:00
|
|
|
} else if (expected && expected.equals) {
|
2013-06-12 17:56:36 -04:00
|
|
|
return QUnit.push(expected.equals(actual), actual, expected, message);
|
2013-02-08 22:37:58 -05:00
|
|
|
}
|
2013-06-12 17:56:36 -04:00
|
|
|
// Let's be strict
|
|
|
|
return strictEqual(actual, expected, message);
|
2011-05-07 12:25:34 -04:00
|
|
|
}
|
2011-05-05 08:38:20 -04:00
|
|
|
|
2011-05-14 13:59:04 -04:00
|
|
|
function test(testName, expected) {
|
|
|
|
return QUnit.test(testName, function() {
|
2011-05-20 09:08:17 -04:00
|
|
|
var project = new Project();
|
2011-05-14 13:59:04 -04:00
|
|
|
expected();
|
2011-05-20 09:08:17 -04:00
|
|
|
project.remove();
|
2011-05-14 13:59:04 -04:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2013-03-17 13:13:55 -04:00
|
|
|
function asyncTest(testName, expected) {
|
|
|
|
return QUnit.asyncTest(testName, function() {
|
|
|
|
var project = new Project();
|
|
|
|
expected(function() {
|
|
|
|
project.remove();
|
|
|
|
start();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2013-04-08 22:51:14 -04:00
|
|
|
function compareNumbers(number1, number2, message, precision) {
|
2013-04-09 20:32:19 -04:00
|
|
|
var formatter = new Formatter(precision);
|
2013-06-23 20:22:13 -04:00
|
|
|
equals(formatter.number(number1),
|
|
|
|
formatter.number(number2), message);
|
2013-04-08 10:07:41 -04:00
|
|
|
}
|
|
|
|
|
2013-04-09 11:40:41 -04:00
|
|
|
function compareArrays(array1, array2, message, precision) {
|
2013-04-09 20:32:19 -04:00
|
|
|
var formatter = new Formatter(precision);
|
2013-04-08 10:07:41 -04:00
|
|
|
function format(array) {
|
|
|
|
return Base.each(array, function(value, index) {
|
2013-06-23 20:22:13 -04:00
|
|
|
this[index] = formatter.number(value);
|
2013-04-08 10:07:41 -04:00
|
|
|
}, []).toString();
|
|
|
|
}
|
|
|
|
equals(format(array1), format(array2), message);
|
2011-02-13 10:48:20 -05:00
|
|
|
}
|
|
|
|
|
2011-02-07 13:28:09 -05:00
|
|
|
function comparePoints(point1, point2, message) {
|
2013-04-08 10:07:41 -04:00
|
|
|
compareNumbers(point1.x, point2.x, (message || '') + ' x');
|
|
|
|
compareNumbers(point1.y, point2.y, (message || '') + ' y');
|
2011-02-13 09:35:48 -05:00
|
|
|
}
|
|
|
|
|
2011-02-13 10:48:20 -05:00
|
|
|
function compareRectangles(rect1, rect2, message) {
|
2013-04-08 10:07:41 -04:00
|
|
|
compareNumbers(rect1.x, rect2.x, (message || '') + ' x');
|
|
|
|
compareNumbers(rect1.y, rect2.y, (message || '') + ' y');
|
|
|
|
compareNumbers(rect1.width, rect2.width, (message || '') + ' width');
|
|
|
|
compareNumbers(rect1.height, rect2.height, (message || '') + ' height');
|
2011-02-13 10:48:20 -05:00
|
|
|
}
|
2011-02-19 11:11:17 -05:00
|
|
|
|
2013-04-09 11:40:41 -04:00
|
|
|
function compareColors(color1, color2, message, precision) {
|
2013-06-11 16:53:48 -04:00
|
|
|
color1 = color1 && new Color(color1);
|
|
|
|
color2 = color2 && new Color(color2);
|
|
|
|
if (color1 && color2) {
|
|
|
|
equals(color1.type, color2.type, (message || '') + ' type');
|
|
|
|
compareArrays(color1.components, color2.components,
|
|
|
|
(message || '') + ' components', precision);
|
|
|
|
} else {
|
|
|
|
equals(color1, color2, message);
|
|
|
|
}
|
2011-05-20 13:39:12 -04:00
|
|
|
}
|
|
|
|
|
2013-04-09 19:46:20 -04:00
|
|
|
function compareStyles(style, style2, checkIdentity) {
|
2011-05-21 13:11:43 -04:00
|
|
|
if (checkIdentity) {
|
|
|
|
equals(function() {
|
2013-01-20 01:27:29 -05:00
|
|
|
return style !== style2;
|
2011-05-21 13:11:43 -04:00
|
|
|
}, true);
|
|
|
|
}
|
2011-05-21 12:38:49 -04:00
|
|
|
Base.each(['fillColor', 'strokeColor'], function(key) {
|
|
|
|
if (style[key]) {
|
|
|
|
// The color should not point to the same color object:
|
2011-05-21 13:11:43 -04:00
|
|
|
if (checkIdentity) {
|
2011-05-21 12:38:49 -04:00
|
|
|
equals(function() {
|
2011-05-21 13:11:43 -04:00
|
|
|
return style[key] !== style2[key];
|
2013-12-11 11:10:09 -05:00
|
|
|
}, true, 'The ' + key
|
|
|
|
+ ' should not point to the same color object:');
|
2011-05-21 13:11:43 -04:00
|
|
|
}
|
2013-04-09 04:30:42 -04:00
|
|
|
if (style[key] instanceof Color) {
|
|
|
|
if (style[key].type === 'gradient' && checkIdentity) {
|
2011-05-21 13:11:43 -04:00
|
|
|
equals(function() {
|
2013-01-20 01:27:29 -05:00
|
|
|
return style[key].gradient === style2[key].gradient;
|
2014-04-06 07:48:03 -04:00
|
|
|
}, true, 'The ' + key
|
2013-12-11 11:10:09 -05:00
|
|
|
+ '.gradient should point to the same object:');
|
2011-05-21 13:11:43 -04:00
|
|
|
}
|
2013-04-09 04:30:42 -04:00
|
|
|
compareColors(style[key], style2[key],
|
2013-04-09 19:46:20 -04:00
|
|
|
'Compare Style#' + key);
|
2011-05-21 12:38:49 -04:00
|
|
|
} else {
|
2013-04-08 10:07:41 -04:00
|
|
|
equals(style[key] && style[key].toString(),
|
|
|
|
style2[key] && style2[key].toString(),
|
2013-04-09 19:46:20 -04:00
|
|
|
'Compare Style#' + key);
|
2011-05-21 12:38:49 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2013-04-09 19:46:20 -04:00
|
|
|
compareObjects('Style', ['strokeCap', 'strokeJoin', 'dashArray',
|
|
|
|
'dashOffset', 'miterLimit', 'strokeOverprint', 'fillOverprint',
|
|
|
|
'fontSize', 'font', 'leading', 'justification'],
|
|
|
|
style, style2, checkIdentity);
|
2011-05-21 12:38:49 -04:00
|
|
|
}
|
|
|
|
|
2011-05-26 05:55:39 -04:00
|
|
|
function compareObjects(name, keys, obj, obj2, checkIdentity) {
|
2011-05-21 12:43:22 -04:00
|
|
|
if (checkIdentity) {
|
|
|
|
equals(function() {
|
2013-01-20 01:27:29 -05:00
|
|
|
return obj !== obj2;
|
2011-05-21 12:43:22 -04:00
|
|
|
}, true);
|
|
|
|
}
|
2011-05-21 12:38:49 -04:00
|
|
|
Base.each(keys, function(key) {
|
2013-04-09 19:46:20 -04:00
|
|
|
var val = obj[key], val2 = obj2[key],
|
|
|
|
message = 'Compare ' + name + '#' + key;
|
|
|
|
if (typeof val === 'number') {
|
|
|
|
compareNumbers(val, val2, message);
|
|
|
|
} else if (Array.isArray(val)) {
|
|
|
|
compareArrays(val, val2, message);
|
|
|
|
} else {
|
|
|
|
equals(val, val2, message);
|
|
|
|
}
|
2011-05-21 12:38:49 -04:00
|
|
|
});
|
2011-05-26 04:20:21 -04:00
|
|
|
}
|
2011-05-21 12:38:49 -04:00
|
|
|
|
2011-05-21 14:36:30 -04:00
|
|
|
function compareSegmentPoints(segmentPoint, segmentPoint2, checkIdentity) {
|
2011-05-26 05:54:46 -04:00
|
|
|
compareObjects('SegmentPoint', ['x', 'y', 'selected'],
|
2011-05-26 04:20:21 -04:00
|
|
|
segmentPoint, segmentPoint2, checkIdentity);
|
2011-05-21 14:36:30 -04:00
|
|
|
}
|
|
|
|
|
2011-05-21 13:41:02 -04:00
|
|
|
function compareSegments(segment, segment2, checkIdentity) {
|
|
|
|
if (checkIdentity) {
|
|
|
|
equals(function() {
|
|
|
|
return segment !== segment2;
|
|
|
|
}, true);
|
|
|
|
}
|
2011-05-21 14:37:25 -04:00
|
|
|
equals(function() {
|
|
|
|
return segment.selected == segment2.selected;
|
|
|
|
}, true);
|
2011-05-26 04:20:21 -04:00
|
|
|
Base.each(['handleIn', 'handleOut', 'point'], function(key) {
|
2011-05-21 14:37:25 -04:00
|
|
|
compareSegmentPoints(segment[key], segment2[key]);
|
2011-05-26 04:20:21 -04:00
|
|
|
});
|
2011-05-21 13:41:02 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
function compareSegmentLists(segmentList, segmentList2, checkIdentity) {
|
|
|
|
if (checkIdentity) {
|
|
|
|
equals(function() {
|
|
|
|
return segmentList !== segmentList2;
|
|
|
|
}, true);
|
|
|
|
}
|
|
|
|
equals(segmentList.toString(), segmentList2.toString(),
|
|
|
|
'Compare Item#segments');
|
|
|
|
if (checkIdentity) {
|
|
|
|
for (var i = 0, l = segmentList.length; i < l; i++) {
|
|
|
|
var segment = segmentList[i],
|
|
|
|
segment2 = segmentList2[i];
|
|
|
|
compareSegments(segment, segment2, checkIdentity);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-03-17 09:42:20 -04:00
|
|
|
function compareItems(item, item2, cloned, checkIdentity, dontShareProject) {
|
2011-05-21 12:43:22 -04:00
|
|
|
if (checkIdentity) {
|
|
|
|
equals(function() {
|
2013-01-20 01:27:29 -05:00
|
|
|
return item !== item2;
|
2011-05-21 12:43:22 -04:00
|
|
|
}, true);
|
2011-07-07 10:09:02 -04:00
|
|
|
|
2011-05-21 13:11:43 -04:00
|
|
|
equals(function() {
|
2013-01-20 01:27:29 -05:00
|
|
|
return item.id !== item2.id;
|
2011-05-21 13:11:43 -04:00
|
|
|
}, true);
|
2011-05-21 12:43:22 -04:00
|
|
|
}
|
2011-05-20 13:39:12 -04:00
|
|
|
|
2011-05-21 12:38:49 -04:00
|
|
|
equals(function() {
|
|
|
|
return item.constructor == item2.constructor;
|
|
|
|
}, true);
|
|
|
|
|
2011-05-20 13:39:12 -04:00
|
|
|
var itemProperties = ['opacity', 'locked', 'visible', 'blendMode', 'name',
|
2013-10-17 07:02:35 -04:00
|
|
|
'selected', 'clipMask', 'guide'];
|
2011-05-20 13:39:12 -04:00
|
|
|
Base.each(itemProperties, function(key) {
|
2013-01-20 01:27:29 -05:00
|
|
|
var value = item[key];
|
|
|
|
// When item was cloned and had a name, the name will be versioned
|
|
|
|
equals(
|
|
|
|
key == 'name' && cloned && value
|
|
|
|
? value + ' 1'
|
|
|
|
: value,
|
|
|
|
item2[key],
|
|
|
|
'compare Item#' + key);
|
2011-05-20 13:39:12 -04:00
|
|
|
});
|
|
|
|
|
2011-05-21 13:11:43 -04:00
|
|
|
if (checkIdentity) {
|
|
|
|
equals(function() {
|
2013-01-20 01:27:29 -05:00
|
|
|
return item.bounds !== item2.bounds;
|
2011-05-21 13:11:43 -04:00
|
|
|
}, true);
|
|
|
|
}
|
2011-05-21 06:49:15 -04:00
|
|
|
|
2011-05-21 12:38:49 -04:00
|
|
|
equals(item.bounds.toString(), item2.bounds.toString(),
|
|
|
|
'Compare Item#bounds');
|
2011-05-21 14:37:25 -04:00
|
|
|
|
|
|
|
if (checkIdentity) {
|
|
|
|
equals(function() {
|
2013-01-20 01:27:29 -05:00
|
|
|
return item.position !== item2.position;
|
2011-05-21 14:37:25 -04:00
|
|
|
}, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
equals(item.position.toString(), item2.position.toString(),
|
|
|
|
'Compare Item#position');
|
2011-07-07 10:09:02 -04:00
|
|
|
|
2013-03-17 11:15:58 -04:00
|
|
|
equals(function() {
|
2013-04-08 10:07:41 -04:00
|
|
|
return Base.equals(item.data, item2.data);
|
2013-03-17 11:15:58 -04:00
|
|
|
}, true);
|
|
|
|
|
2011-05-21 06:48:43 -04:00
|
|
|
if (item.matrix) {
|
2011-05-21 13:11:43 -04:00
|
|
|
if (checkIdentity) {
|
|
|
|
equals(function() {
|
2013-01-20 01:27:29 -05:00
|
|
|
return item.matrix !== item2.matrix;
|
2011-05-21 13:11:43 -04:00
|
|
|
}, true);
|
|
|
|
}
|
2011-05-21 06:48:43 -04:00
|
|
|
equals(item.matrix.toString(), item2.matrix.toString(),
|
2011-05-21 12:38:49 -04:00
|
|
|
'Compare Item#matrix');
|
2011-05-21 06:48:43 -04:00
|
|
|
}
|
2011-05-20 13:39:12 -04:00
|
|
|
|
2011-05-21 13:42:29 -04:00
|
|
|
// Path specific
|
2013-10-17 07:02:35 -04:00
|
|
|
if (item instanceof Path) {
|
2013-03-17 09:42:20 -04:00
|
|
|
var keys = ['closed', 'fullySelected', 'clockwise'];
|
2011-05-21 14:37:25 -04:00
|
|
|
for (var i = 0, l = keys.length; i < l; i++) {
|
|
|
|
var key = keys[i];
|
2011-05-26 05:55:39 -04:00
|
|
|
equals(item[key], item2[key], 'Compare Path#' + key);
|
2011-05-21 14:37:25 -04:00
|
|
|
}
|
2013-03-17 09:42:20 -04:00
|
|
|
compareNumbers(item.length, item2.length, 'Compare Path#length');
|
2011-05-21 13:42:29 -04:00
|
|
|
compareSegmentLists(item.segments, item2.segments, checkIdentity);
|
|
|
|
}
|
2011-05-21 06:49:15 -04:00
|
|
|
|
2013-10-17 07:02:35 -04:00
|
|
|
// Shape specific
|
|
|
|
if (item instanceof Shape) {
|
|
|
|
var keys = ['shape', 'size', 'radius'];
|
|
|
|
for (var i = 0, l = keys.length; i < l; i++) {
|
|
|
|
var key = keys[i];
|
|
|
|
equals(item[key], item2[key], 'Compare Shape#' + key);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-05-20 13:39:12 -04:00
|
|
|
// Group specific
|
|
|
|
if (item instanceof Group) {
|
|
|
|
equals(function() {
|
2011-05-21 12:38:49 -04:00
|
|
|
return item.clipped == item2.clipped;
|
2011-05-20 13:39:12 -04:00
|
|
|
}, true);
|
|
|
|
}
|
2011-05-21 06:49:15 -04:00
|
|
|
|
2011-05-20 13:39:12 -04:00
|
|
|
// Layer specific
|
|
|
|
if (item instanceof Layer) {
|
|
|
|
equals(function() {
|
2013-03-17 09:42:20 -04:00
|
|
|
return dontShareProject
|
|
|
|
? item.project != item2.project
|
|
|
|
: item.project == item2.project;
|
2011-05-20 13:39:12 -04:00
|
|
|
}, true);
|
|
|
|
}
|
2011-05-21 06:49:15 -04:00
|
|
|
|
2011-05-20 13:39:12 -04:00
|
|
|
// PlacedSymbol specific
|
|
|
|
if (item instanceof PlacedSymbol) {
|
2013-03-17 10:39:00 -04:00
|
|
|
if (dontShareProject) {
|
2013-03-19 21:52:10 -04:00
|
|
|
compareItems(item.symbol.definition, item2.symbol.definition,
|
2013-03-17 10:39:00 -04:00
|
|
|
cloned, checkIdentity, dontShareProject,
|
|
|
|
'Compare Symbol#definition');
|
|
|
|
} else {
|
|
|
|
equals(function() {
|
|
|
|
return item.symbol == item2.symbol;
|
|
|
|
}, true);
|
|
|
|
}
|
2011-05-20 13:39:12 -04:00
|
|
|
}
|
2011-05-21 06:47:58 -04:00
|
|
|
|
|
|
|
// Raster specific
|
|
|
|
if (item instanceof Raster) {
|
2013-03-17 11:34:05 -04:00
|
|
|
equals(item.size.toString(), item2.size.toString(),
|
|
|
|
'Compare Raster#size');
|
|
|
|
compareNumbers(item.width, item2.width, 'Compare Raster#width');
|
|
|
|
compareNumbers(item.height, item2.height, 'Compare Raster#height');
|
2013-03-17 19:17:57 -04:00
|
|
|
|
|
|
|
equals(item.ppi.toString(), item2.ppi.toString(),
|
|
|
|
'Compare Raster#ppi');
|
|
|
|
|
2013-03-17 11:34:05 -04:00
|
|
|
equals(item.source, item2.source, 'Compare Raster#source');
|
|
|
|
if (checkIdentity) {
|
|
|
|
equals(item.image, item2.image, 'Compare Raster#image');
|
2011-05-21 06:47:58 -04:00
|
|
|
}
|
2013-03-17 11:34:05 -04:00
|
|
|
equals(item.size.toString(), item2.size.toString(),
|
|
|
|
'Compare Raster#size');
|
2013-04-08 10:07:41 -04:00
|
|
|
equals(item.toDataURL() == item2.toDataURL(), true,
|
|
|
|
'Compare Raster#toDataUrl()');
|
2011-05-21 06:47:58 -04:00
|
|
|
}
|
|
|
|
|
2011-05-20 13:39:12 -04:00
|
|
|
// TextItem specific:
|
|
|
|
if (item instanceof TextItem) {
|
2011-05-21 12:38:49 -04:00
|
|
|
equals(item.content, item2.content, 'Compare Item#content');
|
2011-05-20 13:39:12 -04:00
|
|
|
}
|
2011-07-07 10:09:02 -04:00
|
|
|
|
2011-05-20 13:39:12 -04:00
|
|
|
// PointText specific:
|
|
|
|
if (item instanceof PointText) {
|
2011-05-21 13:11:43 -04:00
|
|
|
if (checkIdentity) {
|
|
|
|
equals(function() {
|
2013-01-20 01:27:29 -05:00
|
|
|
return item.point !== item2.point;
|
2011-05-21 13:11:43 -04:00
|
|
|
}, true);
|
|
|
|
}
|
2011-12-20 17:32:28 -05:00
|
|
|
equals(item.point.toString(), item2.point.toString(),
|
|
|
|
'Compare Item#point');
|
2011-05-20 13:39:12 -04:00
|
|
|
}
|
2011-07-07 10:09:02 -04:00
|
|
|
|
2011-05-21 12:38:49 -04:00
|
|
|
if (item.style) {
|
2013-04-09 19:46:20 -04:00
|
|
|
// Style
|
|
|
|
compareStyles(item.style, item2.style, checkIdentity);
|
2011-05-20 13:39:12 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Check length of children and recursively compare them:
|
|
|
|
if (item.children) {
|
|
|
|
equals(function() {
|
|
|
|
return item.children.length == item2.children.length;
|
|
|
|
}, true);
|
|
|
|
for (var i = 0, l = item.children.length; i < l; i++) {
|
2013-03-19 21:52:10 -04:00
|
|
|
compareItems(item.children[i], item2.children[i], cloned,
|
|
|
|
checkIdentity, dontShareProject);
|
2011-05-20 13:39:12 -04:00
|
|
|
}
|
|
|
|
}
|
2011-05-26 04:20:21 -04:00
|
|
|
}
|
2012-12-01 14:05:48 -05:00
|
|
|
|
2013-03-17 09:42:20 -04:00
|
|
|
function compareProjects(project, project2) {
|
|
|
|
// Compare Project#symbols:
|
|
|
|
equals(function() {
|
|
|
|
return project.symbols.length == project2.symbols.length;
|
|
|
|
}, true);
|
|
|
|
for (var i = 0, l = project.symbols.length; i < l; i++) {
|
|
|
|
var definition1 = project.symbols[i].definition;
|
|
|
|
var definition2 = project2.symbols[i].definition;
|
2013-03-19 21:52:10 -04:00
|
|
|
compareItems(definition1, definition2, false, false, true,
|
|
|
|
'Compare Symbol#definition');
|
2013-03-17 09:42:20 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Compare Project#layers:
|
|
|
|
equals(function() {
|
2013-04-08 10:07:41 -04:00
|
|
|
return project.layers.length == project2.layers.length;
|
2013-03-17 09:42:20 -04:00
|
|
|
}, true);
|
|
|
|
for (var i = 0, l = project.layers.length; i < l; i++) {
|
|
|
|
compareItems(project.layers[i], project2.layers[i], false, false, true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-12-01 14:05:48 -05:00
|
|
|
// SVG
|
|
|
|
|
2013-04-23 10:19:08 -04:00
|
|
|
function createSVG(xml) {
|
2013-12-11 11:10:09 -05:00
|
|
|
return new DOMParser().parseFromString(
|
|
|
|
'<svg xmlns="http://www.w3.org/2000/svg">' + xml + '</svg>',
|
2014-02-12 03:47:43 -05:00
|
|
|
'text/xml');
|
2014-04-06 07:48:03 -04:00
|
|
|
}
|