From 2c632c3d3a7f5b6676b6a4410bf074d37e925bd3 Mon Sep 17 00:00:00 2001 From: abakkk Date: Sun, 7 Jun 2020 20:08:42 +0200 Subject: [PATCH] use `line` svg element for straight lines --- draw.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/draw.js b/draw.js index 88c5e9a..86b1aa7 100644 --- a/draw.js +++ b/draw.js @@ -1003,7 +1003,14 @@ const DrawingElement = new Lang.Class({ let color = this.eraser ? bgColor : this.color; let isStraightLine = this.shape == Shapes.LINE && (points.length < 3 || points[2] == points[1] || points[2] == points[0]); let fill = this.fill && !isStraightLine; - let attributes = `fill="${fill ? color : 'transparent'}" ` + + let attributes; + + if (isStraightLine) + attributes = `stroke="${color}" ` + + `stroke-width="${this.line.lineWidth}" ` + + `stroke-linecap="${LineCapNames[this.line.lineCap].toLowerCase()}"`; + else + attributes = `fill="${fill ? color : 'transparent'}" ` + `stroke="${color}" ` + `${fill ? '' : 'fill-opacity="0"'} ` + `stroke-width="${this.line.lineWidth}" ` + @@ -1018,7 +1025,10 @@ const DrawingElement = new Lang.Class({ row += ` C ${points[0][0]} ${points[0][1]}, ${points[1][0]} ${points[1][1]}, ${points[2][0]} ${points[2][1]}`; row += `${fill ? 'z' : ''}"/>`; - } else if (this.shape == Shapes.NONE || this.shape == Shapes.LINE) { + } else if (this.shape == Shapes.LINE) { + row += ``; + + } else if (this.shape == Shapes.NONE) { row += `