mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-01 02:38:43 -05:00
Implement support for CSS blend-modes in SVGExport.
This commit is contained in:
parent
ecad1c6a0d
commit
85f08825d7
2 changed files with 17 additions and 14 deletions
|
@ -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;
|
||||
|
||||
|
|
|
@ -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];
|
||||
|
|
Loading…
Reference in a new issue