SVG: implement fill opacity

This makes the `eoFill` method similar to the `eoStroke` method and the
ones in `src/display/canvas.js`.
This commit is contained in:
Tim van der Meij 2017-06-23 00:19:20 +02:00
parent 8e9b4b5ff2
commit 440914e49b
No known key found for this signature in database
GPG Key ID: 8C3FD2925A5F2762

View File

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