mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-01 02:38:43 -05:00
parent
8946f44ed9
commit
3c43a78c53
3 changed files with 26 additions and 7 deletions
|
@ -326,8 +326,8 @@ new function() {
|
||||||
definitions = { ids: {}, svgs: {} };
|
definitions = { ids: {}, svgs: {} };
|
||||||
// Use #__id for items that don't have internal #_id properties (Color),
|
// Use #__id for items that don't have internal #_id properties (Color),
|
||||||
// and give them ids from their own private id pool named 'svg'.
|
// and give them ids from their own private id pool named 'svg'.
|
||||||
var id = item._id || item.__id || (item.__id = UID.get('svg'));
|
return item && definitions.svgs[type + '-'
|
||||||
return item && definitions.svgs[type + '-' + id];
|
+ (item._id || item.__id || (item.__id = UID.get('svg')))];
|
||||||
}
|
}
|
||||||
|
|
||||||
function setDefinition(item, node, type) {
|
function setDefinition(item, node, type) {
|
||||||
|
|
|
@ -217,11 +217,9 @@ var comparePixels = function(actual, expected, message, options) {
|
||||||
var tolerance = (options.tolerance || 1e-4) * 100,
|
var tolerance = (options.tolerance || 1e-4) * 100,
|
||||||
fixed = tolerance < 1 ? ((1 / tolerance) + '').length - 1 : 0,
|
fixed = tolerance < 1 ? ((1 / tolerance) + '').length - 1 : 0,
|
||||||
identical = result ? 100 - result.misMatchPercentage : 0,
|
identical = result ? 100 - result.misMatchPercentage : 0,
|
||||||
reached = identical.toFixed(fixed),
|
ok = Math.abs(100 - identical) <= tolerance,
|
||||||
hundred = (100).toFixed(fixed),
|
text = identical.toFixed(fixed) + '% identical';
|
||||||
ok = reached == hundred,
|
QUnit.push(ok, text, (100).toFixed(fixed) + '% identical', message);
|
||||||
text = reached + '% identical';
|
|
||||||
QUnit.push(ok, text, hundred + '% identical', message);
|
|
||||||
if (!ok && result && !isNode) {
|
if (!ok && result && !isNode) {
|
||||||
// Get the right entry for this unit test and assertion, and
|
// Get the right entry for this unit test and assertion, and
|
||||||
// replace the results with images
|
// replace the results with images
|
||||||
|
|
|
@ -191,4 +191,25 @@ if (!isNode) {
|
||||||
tolerance: 1e-2
|
tolerance: 1e-2
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('Export SVG with clipping defs', function(assert) {
|
||||||
|
var group = new Group({
|
||||||
|
children: [
|
||||||
|
new Path.Circle({
|
||||||
|
center: [150, 150],
|
||||||
|
radius: 50
|
||||||
|
}),
|
||||||
|
new Path.Rectangle({
|
||||||
|
point: [100, 100],
|
||||||
|
size: [100, 100],
|
||||||
|
fillColor: 'green'
|
||||||
|
})
|
||||||
|
],
|
||||||
|
clipped: true
|
||||||
|
});
|
||||||
|
var svg = project.exportSVG({ bounds: 'content', asString: true });
|
||||||
|
compareSVG(assert.async(), svg, project.activeLayer, null, {
|
||||||
|
tolerance: 1e-2
|
||||||
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue