mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-01 02:38:43 -05:00
Improve style handling in SvgExporter.
This commit is contained in:
parent
61531949b0
commit
65f1e5c66d
2 changed files with 9 additions and 6 deletions
|
@ -22,7 +22,7 @@
|
||||||
path1.id = "square1";
|
path1.id = "square1";
|
||||||
path1.strokeCap = "square";
|
path1.strokeCap = "square";
|
||||||
path1.opacity = ".1";
|
path1.opacity = ".1";
|
||||||
path1.dashArray = "[5, 2]";
|
path1.dashArray = [5, 2];
|
||||||
path1.dashOffset = "0";
|
path1.dashOffset = "0";
|
||||||
|
|
||||||
var point2 = new Point(75, 75);
|
var point2 = new Point(75, 75);
|
||||||
|
|
|
@ -39,6 +39,7 @@ var SvgExporter = this.SvgExporter = new function() {
|
||||||
children = group._children;
|
children = group._children;
|
||||||
for (var i = 0, l = children.length; i < l; i++)
|
for (var i = 0, l = children.length; i < l; i++)
|
||||||
svg.appendChild(SvgExporter.exportItem(children[i]));
|
svg.appendChild(SvgExporter.exportItem(children[i]));
|
||||||
|
applyStyle(group, svg);
|
||||||
return svg;
|
return svg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -339,7 +340,8 @@ var SvgExporter = this.SvgExporter = new function() {
|
||||||
function applyStyle(item, svg) {
|
function applyStyle(item, svg) {
|
||||||
var attrs = {},
|
var attrs = {},
|
||||||
style = item._style,
|
style = item._style,
|
||||||
parentStyle = item.getParent()._style,
|
parent = item.getParent(),
|
||||||
|
parentStyle = parent && parent._style,
|
||||||
properties = {
|
properties = {
|
||||||
fillColor: 'fill',
|
fillColor: 'fill',
|
||||||
strokeColor: 'stroke',
|
strokeColor: 'stroke',
|
||||||
|
@ -361,14 +363,15 @@ var SvgExporter = this.SvgExporter = new function() {
|
||||||
// Get a given style only if it differs from the value on the parent
|
// Get a given style only if it differs from the value on the parent
|
||||||
// (A layer or group which can have style values in SVG).
|
// (A layer or group which can have style values in SVG).
|
||||||
var getter = 'get' + Base.capitalize(name),
|
var getter = 'get' + Base.capitalize(name),
|
||||||
value = style[getter](),
|
value = style[getter]();
|
||||||
parent = parentStyle[getter]();
|
if (value != null && (!parentStyle
|
||||||
if (!Base.equals(parent, value)) {
|
|| !Base.equals(parentStyle[getter](), value))) {
|
||||||
attrs[svgName] = value && /Color$/.test(name)
|
value = /Color$/.test(name)
|
||||||
? value.toCssString()
|
? value.toCssString()
|
||||||
: name == 'dashArray'
|
: name == 'dashArray'
|
||||||
? value.join(',')
|
? value.join(',')
|
||||||
: value;
|
: value;
|
||||||
|
attrs[svgName] = value;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue