Implement support for CSS blend-modes in SVGExport.

This commit is contained in:
Jürg Lehni 2015-12-28 00:44:02 +01:00
parent ecad1c6a0d
commit 85f08825d7
2 changed files with 17 additions and 14 deletions

View file

@ -284,7 +284,8 @@ new function() {
function applyStyle(item, node, isRoot) {
var attrs = {},
parent = !isRoot && item.getParent();
parent = !isRoot && item.getParent(),
style = [];
if (item._name != null)
attrs.id = item._name;
@ -306,23 +307,25 @@ new function() {
if (alpha < 1)
attrs[entry.attribute + '-opacity'] = alpha;
}
attrs[entry.attribute] = value == null
? 'none'
: type === 'number'
? formatter.number(value)
: type === 'color'
? value.gradient
? exportGradient(value, item)
if (type === 'style') {
style.push(entry.attribute + ': ' + value)
} else {
attrs[entry.attribute] = value == null ? 'none'
: type === 'number' ? formatter.number(value)
: type === 'color' ? value.gradient
// true for noAlpha, see above
? exportGradient(value, item)
: value.toCSS(true)
: type === 'array'
? value.join(',')
: type === 'lookup'
? entry.toSVG[value]
: value;
: type === 'array' ? value.join(',')
: type === 'lookup' ? entry.toSVG[value]
: value;
}
}
});
if (style.length)
attrs.style = style.join(';');
if (attrs.opacity === 1)
delete attrs.opacity;

View file

@ -43,7 +43,7 @@ var SVGStyles = Base.each({
}],
// Item
opacity: ['opacity', 'number'],
blendMode: ['mix-blend-mode', 'string']
blendMode: ['mix-blend-mode', 'style']
}, function(entry, key) {
var part = Base.capitalize(key),
lookup = entry[2];