mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-06 04:42:15 -05:00
Define #_type property for both Symbol and Gradient and use it in SvgExport.
This commit is contained in:
parent
224563d5f7
commit
629e16144a
3 changed files with 9 additions and 4 deletions
|
@ -16,6 +16,8 @@
|
|||
* @class The Gradient object.
|
||||
*/
|
||||
var Gradient = this.Gradient = Base.extend(/** @lends Gradient# */{
|
||||
_type: 'gradient',
|
||||
|
||||
// TODO: Should type here be called 'radial' and have it receive a
|
||||
// boolean value?
|
||||
/**
|
||||
|
|
|
@ -20,6 +20,8 @@
|
|||
* to be updated with every transformation.
|
||||
*/
|
||||
var Symbol = this.Symbol = Base.extend(/** @lends Symbol# */{
|
||||
_type: 'symbol',
|
||||
|
||||
/**
|
||||
* Creates a Symbol item.
|
||||
*
|
||||
|
|
|
@ -364,7 +364,7 @@ new function() {
|
|||
viewBox: formatRectangle(bounds)
|
||||
});
|
||||
symbolNode.appendChild(exportSvg(definition));
|
||||
setDefinition(symbol, symbolNode, 'symbol');
|
||||
setDefinition(symbol, symbolNode);
|
||||
}
|
||||
attrs.href = '#' + symbolNode.id;
|
||||
attrs.x += bounds.x;
|
||||
|
@ -421,7 +421,7 @@ new function() {
|
|||
attrs['stop-opacity'] = color._alpha;
|
||||
gradientNode.appendChild(createElement('stop', attrs));
|
||||
}
|
||||
setDefinition(gradient, gradientNode, 'gradient');
|
||||
setDefinition(gradient, gradientNode);
|
||||
}
|
||||
return 'url(#' + gradientNode.id + ')';
|
||||
}
|
||||
|
@ -485,8 +485,9 @@ new function() {
|
|||
return definitions.svgs[item._id];
|
||||
}
|
||||
|
||||
function setDefinition(item, node, type) {
|
||||
var id = definitions.ids[type] = (definitions.ids[type] || 0) + 1;
|
||||
function setDefinition(item, node) {
|
||||
var type = item._type,
|
||||
id = definitions.ids[type] = (definitions.ids[type] || 0) + 1;
|
||||
node.id = type + '-' + id;
|
||||
definitions.svgs[item._id] = node;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue