From 440914e49b96021314fb67829c32d63e22e3f1b8 Mon Sep 17 00:00:00 2001
From: Tim van der Meij <timvandermeij@gmail.com>
Date: Fri, 23 Jun 2017 00:19:20 +0200
Subject: [PATCH 1/2] SVG: implement fill opacity

This makes the `eoFill` method similar to the `eoStroke` method and the
ones in `src/display/canvas.js`.
---
 src/display/svg.js | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/src/display/svg.js b/src/display/svg.js
index 2aa214824..4a357f00b 100644
--- a/src/display/svg.js
+++ b/src/display/svg.js
@@ -807,6 +807,9 @@ SVGGraphics = (function SVGGraphicsClosure() {
       var color = Util.makeCssRgb(r, g, b);
       this.current.strokeColor = color;
     },
+    setFillAlpha: function SVGGraphics_setFillAlpha(fillAlpha) {
+      this.current.fillAlpha = fillAlpha;
+    },
     setFillRGBColor: function SVGGraphics_setFillRGBColor(r, g, b) {
       var color = Util.makeCssRgb(r, g, b);
       this.current.fillColor = color;
@@ -970,6 +973,9 @@ SVGGraphics = (function SVGGraphicsClosure() {
           case 'Font':
             this.setFont(value);
             break;
+          case 'ca':
+            this.setFillAlpha(value);
+            break;
           default:
             warn('Unimplemented graphic state ' + key);
             break;
@@ -980,6 +986,7 @@ SVGGraphics = (function SVGGraphicsClosure() {
     fill: function SVGGraphics_fill() {
       var current = this.current;
       current.element.setAttributeNS(null, 'fill', current.fillColor);
+      current.element.setAttributeNS(null, 'fill-opacity', current.fillAlpha);
     },
 
     stroke: function SVGGraphics_stroke() {
@@ -989,9 +996,8 @@ SVGGraphics = (function SVGGraphicsClosure() {
     },
 
     eoFill: function SVGGraphics_eoFill() {
-      var current = this.current;
-      current.element.setAttributeNS(null, 'fill', current.fillColor);
-      current.element.setAttributeNS(null, 'fill-rule', 'evenodd');
+      this.current.element.setAttributeNS(null, 'fill-rule', 'evenodd');
+      this.fill();
     },
 
     fillStroke: function SVGGraphics_fillStroke() {

From f9eafefa0966a3527364fb7e596c01157f119aee Mon Sep 17 00:00:00 2001
From: Tim van der Meij <timvandermeij@gmail.com>
Date: Fri, 23 Jun 2017 00:24:47 +0200
Subject: [PATCH 2/2] SVG: implement stroke opacity

---
 src/display/svg.js | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/src/display/svg.js b/src/display/svg.js
index 4a357f00b..edd9ab54c 100644
--- a/src/display/svg.js
+++ b/src/display/svg.js
@@ -803,6 +803,9 @@ SVGGraphics = (function SVGGraphicsClosure() {
     setMiterLimit: function SVGGraphics_setMiterLimit(limit) {
       this.current.miterLimit = limit;
     },
+    setStrokeAlpha: function SVGGraphics_setStrokeAlpha(strokeAlpha) {
+      this.current.strokeAlpha = strokeAlpha;
+    },
     setStrokeRGBColor: function SVGGraphics_setStrokeRGBColor(r, g, b) {
       var color = Util.makeCssRgb(r, g, b);
       this.current.strokeColor = color;
@@ -973,6 +976,9 @@ SVGGraphics = (function SVGGraphicsClosure() {
           case 'Font':
             this.setFont(value);
             break;
+          case 'CA':
+            this.setStrokeAlpha(value);
+            break;
           case 'ca':
             this.setFillAlpha(value);
             break;
@@ -992,6 +998,8 @@ SVGGraphics = (function SVGGraphicsClosure() {
     stroke: function SVGGraphics_stroke() {
       var current = this.current;
       current.element.setAttributeNS(null, 'stroke', current.strokeColor);
+      current.element.setAttributeNS(null, 'stroke-opacity',
+                                     current.strokeAlpha);
       current.element.setAttributeNS(null, 'fill', 'none');
     },