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

View file

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