diff --git a/lcl/interfaces/carbon/carboncanvas.pp b/lcl/interfaces/carbon/carboncanvas.pp index c8838dfc1e..3d37ffe1d2 100644 --- a/lcl/interfaces/carbon/carboncanvas.pp +++ b/lcl/interfaces/carbon/carboncanvas.pp @@ -1168,23 +1168,32 @@ end; the current position ------------------------------------------------------------------------------} procedure TCarbonDeviceContext.LineTo(X, Y: Integer); +var + deltaX, deltaY, absDeltaX, absDeltaY, clipDeltaX, clipDeltaY: Float32; begin - if CurrentPen.Width = 1 then + deltaX := X - PenPos.x; + deltaY := Y - PenPos.y; + absDeltaX := Abs(deltaX); + absDeltaY := Abs(deltaY); + // exclude the end-point from the rasterization + if (absDeltaX > 1.0) or (absDeltaY > 1.0) then begin - CGContextSaveGState(CGContext); - ExcludeClipRect(X, Y, X + 1, Y + 1); - end; - - try + if absDeltaX > absDeltaY then + begin + if deltaX > 0 then clipDeltaX := -1.0 else clipDeltaX := 1.0; + clipDeltaY := clipDeltaX * deltaY / deltaX; + end + else + begin + if deltaY > 0 then clipDeltaY := -1.0 else clipDeltaY := 1.0; + clipDeltaX := clipDeltaY * deltaX / deltaY; + end; CGContextBeginPath(CGContext); // add 0.5 to both coordinates for better rasterization CGContextMoveToPoint(CGContext, PenPos.x + 0.5, PenPos.y + 0.5); - CGContextAddLineToPoint(CGContext, X + 0.5, Y + 0.5); + CGContextAddLineToPoint(CGContext, X + clipDeltaX + 0.5, Y + clipDeltaY + 0.5); CGContextStrokePath(CGContext); - finally - if CurrentPen.Width = 1 then CGContextRestoreGState(CGContext); end; - FPenPos.x := X; FPenPos.y := Y; end;