From f8b0c5548c5c8fd1cece297bae19df3cc4d8a94b Mon Sep 17 00:00:00 2001 From: Thomas Geymayer Date: Mon, 29 Jan 2018 09:10:58 +0100 Subject: [PATCH] parsesvg: use new stroke-opacity and fill-opacity properties --- Nasal/canvas/svg.nas | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/Nasal/canvas/svg.nas b/Nasal/canvas/svg.nas index d7fe570a3..dfb61adc3 100644 --- a/Nasal/canvas/svg.nas +++ b/Nasal/canvas/svg.nas @@ -525,22 +525,26 @@ var parsesvg = func(group, path, options = nil) } else parsePath(attr['d']); - - var fillOpacity = style['fill-opacity']; - if( fillOpacity != nil) - stack[-1].set('fill', style['fill'] ~ sprintf("%02x", int(style['fill-opacity']*255))); - else - stack[-1].set('fill', style['fill']); + + var fill = style['fill']; + if( fill != nil ) + stack[-1].set('fill', fill); + + var fill_opacity = style['fill-opacity']; + if( fill_opacity != nil) + stack[-1].setDouble('fill-opacity', fill_opacity); + + var stroke = style['stroke']; + if( stroke != nil ) + stack[-1].set('stroke', stroke); + + var stroke_opacity = style['stroke-opacity']; + if( stroke_opacity != nil) + stack[-1].setDouble('stroke-opacity', stroke_opacity); var w = style['stroke-width']; stack[-1].setStrokeLineWidth( w != nil ? evalCSSNum(w) : 1 ); - - var strokeOpacity = style['stroke-opacity']; - if(strokeOpacity != nil) - stack[-1].set('stroke', (style['stroke'] ~ sprintf("%02x", int(style['stroke-opacity']*255)))); - else - stack[-1].set('stroke', style['stroke'] or "none"); - + var linecap = style['stroke-linecap']; if( linecap != nil ) stack[-1].setStrokeLineCap(style['stroke-linecap']); @@ -549,7 +553,6 @@ var parsesvg = func(group, path, options = nil) if( linejoin != nil ) stack[-1].setStrokeLineJoin(style['stroke-linejoin']); - # http://www.w3.org/TR/SVG/painting.html#StrokeDasharrayProperty var dash = style['stroke-dasharray']; if( dash and size(dash) > 3 )