Merge pull request #8564 from timvandermeij/svg-opacity

SVG: implement fill and stroke opacity
This commit is contained in:
Jonas Jenwald 2017-06-24 22:42:18 +02:00 committed by GitHub
commit 859e3d4dce

View File

@ -805,10 +805,16 @@ SVGGraphics = (function SVGGraphicsClosure() {
setMiterLimit: function SVGGraphics_setMiterLimit(limit) { setMiterLimit: function SVGGraphics_setMiterLimit(limit) {
this.current.miterLimit = limit; this.current.miterLimit = limit;
}, },
setStrokeAlpha: function SVGGraphics_setStrokeAlpha(strokeAlpha) {
this.current.strokeAlpha = strokeAlpha;
},
setStrokeRGBColor: function SVGGraphics_setStrokeRGBColor(r, g, b) { setStrokeRGBColor: function SVGGraphics_setStrokeRGBColor(r, g, b) {
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;
@ -978,6 +984,12 @@ SVGGraphics = (function SVGGraphicsClosure() {
case 'Font': case 'Font':
this.setFont(value); this.setFont(value);
break; break;
case 'CA':
this.setStrokeAlpha(value);
break;
case 'ca':
this.setFillAlpha(value);
break;
default: default:
warn('Unimplemented graphic state ' + key); warn('Unimplemented graphic state ' + key);
break; break;
@ -988,18 +1000,20 @@ 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() {
var current = this.current; var current = this.current;
current.element.setAttributeNS(null, 'stroke', current.strokeColor); current.element.setAttributeNS(null, 'stroke', current.strokeColor);
current.element.setAttributeNS(null, 'stroke-opacity',
current.strokeAlpha);
current.element.setAttributeNS(null, 'fill', 'none'); current.element.setAttributeNS(null, 'fill', 'none');
}, },
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() {