From 7b71a8f361ce735372ed1cbacd7a2b66226d4e73 Mon Sep 17 00:00:00 2001 From: www2 Date: Thu, 9 Apr 2015 00:51:24 +0200 Subject: [PATCH 1/2] Add Alpha channel for fill and stroke --- Nasal/canvas/svg.nas | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/Nasal/canvas/svg.nas b/Nasal/canvas/svg.nas index b542b31c3..6d8713220 100644 --- a/Nasal/canvas/svg.nas +++ b/Nasal/canvas/svg.nas @@ -525,13 +525,21 @@ var parsesvg = func(group, path, options = nil) } else parsePath(attr['d']); - - stack[-1].set('fill', style['fill']); + + 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 w = style['stroke-width']; stack[-1].setStrokeLineWidth( w != nil ? evalCSSNum(w) : 1 ); - stack[-1].set('stroke', style['stroke'] or "none"); - + 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']); From acb88337f2f31104752230cdc755143211a46ec5 Mon Sep 17 00:00:00 2001 From: www2 Date: Fri, 10 Apr 2015 21:09:14 +0200 Subject: [PATCH 2/2] add var to fillOpacity and strokeOpacity --- Nasal/canvas/svg.nas | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Nasal/canvas/svg.nas b/Nasal/canvas/svg.nas index 6d8713220..d7fe570a3 100644 --- a/Nasal/canvas/svg.nas +++ b/Nasal/canvas/svg.nas @@ -526,7 +526,7 @@ var parsesvg = func(group, path, options = nil) else parsePath(attr['d']); - fillOpacity = style['fill-opacity']; + var fillOpacity = style['fill-opacity']; if( fillOpacity != nil) stack[-1].set('fill', style['fill'] ~ sprintf("%02x", int(style['fill-opacity']*255))); else @@ -534,7 +534,8 @@ var parsesvg = func(group, path, options = nil) var w = style['stroke-width']; stack[-1].setStrokeLineWidth( w != nil ? evalCSSNum(w) : 1 ); - strokeOpacity = style['stroke-opacity']; + + var strokeOpacity = style['stroke-opacity']; if(strokeOpacity != nil) stack[-1].set('stroke', (style['stroke'] ~ sprintf("%02x", int(style['stroke-opacity']*255)))); else