SRL Archive - SRL Archives

CorrectBox


Bad Boy JH

2010-05-25 03:33:00

This procedure swaps x1 and x2 and/or y1 and y2 so that the 1 values are less than the 2 values, and as such form a correct box, cause if the 2nd value is larger than the 1st it doesn't work.

Procedure CorrectBox(var Box:TBox);
var
TPnt:TPoint;
begin
if Box.X1 > Box.X2 then
begin
TPnt.X := Box.X1;
Box.X1 := Box.X2;
Box.X2 := TPnt.X
end;
if Box.Y1 > Box.Y2 then
begin
TPnt.Y := Box.Y1;
Box.Y1 := Box.Y2;
Box.Y2 := TPnt.Y
end;
end;

i luffs yeww

2010-05-25 03:46:58

I think this could be shortened with try..except? :) Nifty idea, though.

Gu3st...

2010-05-25 07:55:38

I know Simba already does that in some places if not all :)

Sir R. M8gic1an

2010-05-25 15:48:14

From: Zyt3x
I know Simba already does that in some places if not all :)


Exactly. Instead of repeating it all over the place, have a function for it ;)

~RM