Filling and stroking empty paths in SVG backend

This commit is contained in:
Jani Pehkonen 2017-11-14 18:35:39 +02:00
parent 92fcfce685
commit 4e8f7070da

View File

@ -1001,9 +1001,11 @@ SVGGraphics = (function SVGGraphicsClosure() {
closePath: function SVGGraphics_closePath() { closePath: function SVGGraphics_closePath() {
var current = this.current; var current = this.current;
if (current.path) {
var d = current.path.getAttributeNS(null, 'd'); var d = current.path.getAttributeNS(null, 'd');
d += 'Z'; d += 'Z';
current.path.setAttributeNS(null, 'd', d); current.path.setAttributeNS(null, 'd', d);
}
}, },
setLeading: function SVGGraphics_setLeading(leading) { setLeading: function SVGGraphics_setLeading(leading) {
@ -1058,20 +1060,24 @@ SVGGraphics = (function SVGGraphicsClosure() {
fill: function SVGGraphics_fill() { fill: function SVGGraphics_fill() {
var current = this.current; var current = this.current;
if (current.element) {
current.element.setAttributeNS(null, 'fill', current.fillColor); current.element.setAttributeNS(null, 'fill', current.fillColor);
current.element.setAttributeNS(null, 'fill-opacity', current.fillAlpha); current.element.setAttributeNS(null, 'fill-opacity', current.fillAlpha);
}
}, },
stroke: function SVGGraphics_stroke() { stroke: function SVGGraphics_stroke() {
var current = this.current; var current = this.current;
if (current.element) {
current.element.setAttributeNS(null, 'stroke', current.strokeColor); current.element.setAttributeNS(null, 'stroke', current.strokeColor);
current.element.setAttributeNS(null, 'stroke-opacity', current.element.setAttributeNS(null, 'stroke-opacity',
current.strokeAlpha); current.strokeAlpha);
current.element.setAttributeNS(null, 'stroke-miterlimit', current.element.setAttributeNS(null, 'stroke-miterlimit',
pf(current.miterLimit)); pf(current.miterLimit));
current.element.setAttributeNS(null, 'stroke-linecap', current.lineCap); current.element.setAttributeNS(null, 'stroke-linecap', current.lineCap);
current.element.setAttributeNS(null, 'stroke-linejoin', current.lineJoin); current.element.setAttributeNS(null, 'stroke-linejoin',
current.lineJoin);
current.element.setAttributeNS(null, 'stroke-width', current.element.setAttributeNS(null, 'stroke-width',
pf(current.lineWidth) + 'px'); pf(current.lineWidth) + 'px');
current.element.setAttributeNS(null, 'stroke-dasharray', current.element.setAttributeNS(null, 'stroke-dasharray',
@ -1080,10 +1086,13 @@ SVGGraphics = (function SVGGraphicsClosure() {
pf(current.dashPhase) + 'px'); pf(current.dashPhase) + 'px');
current.element.setAttributeNS(null, 'fill', 'none'); current.element.setAttributeNS(null, 'fill', 'none');
}
}, },
eoFill: function SVGGraphics_eoFill() { eoFill: function SVGGraphics_eoFill() {
if (this.current.element) {
this.current.element.setAttributeNS(null, 'fill-rule', 'evenodd'); this.current.element.setAttributeNS(null, 'fill-rule', 'evenodd');
}
this.fill(); this.fill();
}, },
@ -1095,7 +1104,9 @@ SVGGraphics = (function SVGGraphicsClosure() {
}, },
eoFillStroke: function SVGGraphics_eoFillStroke() { eoFillStroke: function SVGGraphics_eoFillStroke() {
if (this.current.element) {
this.current.element.setAttributeNS(null, 'fill-rule', 'evenodd'); this.current.element.setAttributeNS(null, 'fill-rule', 'evenodd');
}
this.fillStroke(); this.fillStroke();
}, },