mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-20 22:39:50 -05:00
Avoid rgba() colors in SVG output since it's not part of SVG 1.1
Use fill- / stroke-opacity instead.
This commit is contained in:
parent
f1abdccf85
commit
86d3a3521b
2 changed files with 8 additions and 3 deletions
|
@ -477,10 +477,10 @@ var Color = this.Color = Base.extend(new function() {
|
|||
/**
|
||||
* @return {String} A css string representation of the color.
|
||||
*/
|
||||
toCss: function() {
|
||||
toCss: function(withAlpha) {
|
||||
if (!this._css) {
|
||||
var color = this.convert('rgb'),
|
||||
alpha = color.getAlpha(),
|
||||
alpha = withAlpha === undefined || withAlpha ? color.getAlpha() : 1,
|
||||
components = [
|
||||
Math.round(color._red * 255),
|
||||
Math.round(color._green * 255),
|
||||
|
|
|
@ -341,10 +341,15 @@ new function() {
|
|||
// (A layer or group which can have style values in SVG).
|
||||
var value = style[entry.get]();
|
||||
if (!parentStyle || !Base.equals(parentStyle[entry.get](), value)) {
|
||||
// Support for css-style rgba() values is not in SVG 1.1, so
|
||||
// separate the alpha value of colors with alpha into the
|
||||
// separate fill- / stroke-opacity attribute:
|
||||
if (entry.type === 'color' && value != null && value.getAlpha() < 1)
|
||||
attrs[entry.attribute + '-opacity'] = value.getAlpha();
|
||||
attrs[entry.attribute] = value == null
|
||||
? 'none'
|
||||
: entry.type === 'color'
|
||||
? value.toCss()
|
||||
? value.toCss(false)
|
||||
: entry.type === 'array'
|
||||
? value.join(',')
|
||||
: entry.type === 'number'
|
||||
|
|
Loading…
Reference in a new issue