Подскажите функцию пересечения обьектов.
В PascalABC эта функция была intersect.
ob1.intersect(ob2) (boolean).
Модератор: Модераторы
function IntersectRect(out Rect: TRect; const R1, R2: TRect): Boolean;
begin
Rect := R1;
if R2.Left > R1.Left then Rect.Left := R2.Left;
if R2.Top > R1.Top then Rect.Top := R2.Top;
if R2.Right < R1.Right then Rect.Right := R2.Right;
if R2.Bottom < R1.Bottom then Rect.Bottom := R2.Bottom;
Result := not IsRectEmpty(Rect);
if not Result then FillChar(Rect, SizeOf(Rect), 0);
end;
function IsRectEmpty(const Rect: TRect): Boolean;
begin
Result := (Rect.Right <= Rect.Left) or (Rect.Bottom <= Rect.Top);
end;
function Intersect(R1:TImage ; R2:TImage): Boolean;
var x,y,kx,ky,a,b,ka,kb:integer;
begin
x:=r1.Width;
y:=r1.height;
kx:=r1.Left;
ky:=r1.Top;
a:=r2.Width;
b:=r2.Height;
ka:=r2.Left;
kb:=r2.top;
intersect:=false;
if (ka>=kx-a)and(ka<=kx+x)and(kb>=ky-b)and(kb<=ky+y) then intersect:=true;
end;
Сейчас этот форум просматривают: Yandex [Bot] и гости: 254