fix for #14550 by Adriaan van Os

git-svn-id: trunk@21647 -
This commit is contained in:
dmitry 2009-09-10 21:06:11 +00:00
parent 20cab5a990
commit e64f3abce1

View File

@ -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;