Browse Source

SVG: implement fill opacity

This makes the `eoFill` method similar to the `eoStroke` method and the
ones in `src/display/canvas.js`.
Tim van der Meij 8 years ago
parent
commit
440914e49b
No known key found for this signature in database
GPG Key ID: 8C3FD2925A5F2762
  1. 12
      src/display/svg.js

12
src/display/svg.js

@ -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() {

Loading…
Cancel
Save