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:
Jürg Lehni 2012-12-01 12:44:54 -08:00
parent f1abdccf85
commit 86d3a3521b
2 changed files with 8 additions and 3 deletions

View file

@ -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),

View file

@ -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'