mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-08 05:42:07 -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.
|
* @class The Gradient object.
|
||||||
*/
|
*/
|
||||||
var Gradient = this.Gradient = Base.extend(/** @lends Gradient# */{
|
var Gradient = this.Gradient = Base.extend(/** @lends Gradient# */{
|
||||||
|
_type: 'gradient',
|
||||||
|
|
||||||
// TODO: Should type here be called 'radial' and have it receive a
|
// TODO: Should type here be called 'radial' and have it receive a
|
||||||
// boolean value?
|
// boolean value?
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -20,6 +20,8 @@
|
||||||
* to be updated with every transformation.
|
* to be updated with every transformation.
|
||||||
*/
|
*/
|
||||||
var Symbol = this.Symbol = Base.extend(/** @lends Symbol# */{
|
var Symbol = this.Symbol = Base.extend(/** @lends Symbol# */{
|
||||||
|
_type: 'symbol',
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a Symbol item.
|
* Creates a Symbol item.
|
||||||
*
|
*
|
||||||
|
|
|
@ -364,7 +364,7 @@ new function() {
|
||||||
viewBox: formatRectangle(bounds)
|
viewBox: formatRectangle(bounds)
|
||||||
});
|
});
|
||||||
symbolNode.appendChild(exportSvg(definition));
|
symbolNode.appendChild(exportSvg(definition));
|
||||||
setDefinition(symbol, symbolNode, 'symbol');
|
setDefinition(symbol, symbolNode);
|
||||||
}
|
}
|
||||||
attrs.href = '#' + symbolNode.id;
|
attrs.href = '#' + symbolNode.id;
|
||||||
attrs.x += bounds.x;
|
attrs.x += bounds.x;
|
||||||
|
@ -421,7 +421,7 @@ new function() {
|
||||||
attrs['stop-opacity'] = color._alpha;
|
attrs['stop-opacity'] = color._alpha;
|
||||||
gradientNode.appendChild(createElement('stop', attrs));
|
gradientNode.appendChild(createElement('stop', attrs));
|
||||||
}
|
}
|
||||||
setDefinition(gradient, gradientNode, 'gradient');
|
setDefinition(gradient, gradientNode);
|
||||||
}
|
}
|
||||||
return 'url(#' + gradientNode.id + ')';
|
return 'url(#' + gradientNode.id + ')';
|
||||||
}
|
}
|
||||||
|
@ -485,8 +485,9 @@ new function() {
|
||||||
return definitions.svgs[item._id];
|
return definitions.svgs[item._id];
|
||||||
}
|
}
|
||||||
|
|
||||||
function setDefinition(item, node, type) {
|
function setDefinition(item, node) {
|
||||||
var id = definitions.ids[type] = (definitions.ids[type] || 0) + 1;
|
var type = item._type,
|
||||||
|
id = definitions.ids[type] = (definitions.ids[type] || 0) + 1;
|
||||||
node.id = type + '-' + id;
|
node.id = type + '-' + id;
|
||||||
definitions.svgs[item._id] = node;
|
definitions.svgs[item._id] = node;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue