mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-15 23:39:24 +02:00
LCL: Fix incorrect clipping by ellipse in TLazCanvas.
(cherry picked from commit e3580cd0b0
)
This commit is contained in:
parent
cb1b303b34
commit
eda6b3c1df
@ -164,17 +164,27 @@ end;
|
|||||||
{
|
{
|
||||||
The equation of the inner area of an axis aligned ellipse:
|
The equation of the inner area of an axis aligned ellipse:
|
||||||
|
|
||||||
(X/a)^2 + (Y/b)^2 <= 1
|
((X-Xc)/a)^2 + ((Y-Yc)/b)^2 <= 1
|
||||||
|
|
||||||
|
where Xc = (X1 + X2)/2 and Yc = (Y1 + Y2)/2 (ellipse center
|
||||||
|
and a = (X2 - X1)/2 and b = (Y2 - Y1)/2 (half axes)
|
||||||
|
|
||||||
|
or:
|
||||||
|
|
||||||
|
((2 X - (X1+X2)) / (X2-X1))^2 + ((2 Y - (Y1+X2)) / (Y2-Y1))^2 <= 1
|
||||||
}
|
}
|
||||||
function TLazRegionEllipse.IsPointInPart(AX, AY: Integer): Boolean;
|
function TLazRegionEllipse.IsPointInPart(AX, AY: Integer): Boolean;
|
||||||
var
|
|
||||||
a, b: Integer;
|
|
||||||
begin
|
begin
|
||||||
a := X2 - X1;
|
if (X2 < X1) or (Y2 < Y1) then
|
||||||
b := Y2 - Y1;
|
Result := false
|
||||||
if (a < 0) or (b < 0) then Exit(False);
|
else
|
||||||
|
if (X1 = X2) then
|
||||||
Result := Sqr(AX/a) + Sqr(AY/b) <= 1;
|
Result := (AX = X1) and (AY >= Y1) and (AY <= Y2)
|
||||||
|
else
|
||||||
|
if (Y1 = Y2) then
|
||||||
|
Result := (AY = Y1) and (AX >= X1) and (AX <= X2)
|
||||||
|
else
|
||||||
|
Result := sqr((AX*2 - (X2+X1)) / (X2-X1)) + sqr((AY*2 - (Y1+Y2)) / (Y2 - Y1)) <= 1;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ TLazRegionPart }
|
{ TLazRegionPart }
|
||||||
|
Loading…
Reference in New Issue
Block a user