Skip to content

Commit af1ea83

Browse files
committed
bfix: Change drawPlotLines to draw a single polyline.
1 parent 0b5478c commit af1ea83

14 files changed

+13
-6
lines changed

Sources/QuartzRenderer/QuartzRenderer.swift

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -408,13 +408,20 @@ public class QuartzRenderer: Renderer {
408408
strokeColor: Color,
409409
isDashed: Bool) {
410410
guard !p.isEmpty else { return }
411-
for i in 0..<p.count-1 {
412-
drawLine(startPoint: p[i],
413-
endPoint: p[i+1],
414-
strokeWidth: thickness,
415-
strokeColor: strokeColor,
416-
isDashed: isDashed)
411+
let line = CGMutablePath()
412+
line.move(to: CGPoint(x: CGFloat(p[0].x + xOffset), y: CGFloat(p[0].y + yOffset)))
413+
for point in p[1...] {
414+
line.addLine(to: CGPoint(x: CGFloat(point.x + xOffset), y: CGFloat(point.y + yOffset)))
415+
}
416+
context.setStrokeColor(strokeColor.cgColor)
417+
context.setLineWidth(CGFloat(thickness))
418+
context.addPath(line)
419+
if(isDashed) {
420+
let dashes: [ CGFloat ] = [ CGFloat(thickness + 1), CGFloat(thickness + 1) ]
421+
context.setLineDash(phase: 1, lengths: dashes)
417422
}
423+
context.strokePath()
424+
context.setLineDash(phase: 1, lengths: [])
418425
}
419426

420427
public func drawText(text s: String,
-11 Bytes
Loading
-16 Bytes
Loading
-20 Bytes
Loading
-79 Bytes
Loading
11 Bytes
Loading
-2.17 KB
Loading
-45 Bytes
Loading
-372 Bytes
Loading
-628 Bytes
Loading

0 commit comments

Comments
 (0)