SRL Archive - OSR Help

boxtoint?


m3gaman3g3nd

2012-01-12 22:18:02

is there a way to convert a tbox to integers ie. x1, x2, y1, y2.

I know that a box contains 2 points right? if so maybe there's a way to do point to integers as well ie. ex, es, yx, ys .

Dgby714

2012-01-12 22:22:54

Box.X1, Box.Y1, Box.X2, Box.Y2

RISK

2012-01-12 22:23:52

procedure Example;
var
B, b2: TBox;
begin
B := (IntToBox(100, 200, 300, 400));

WriteLn(ToStr(B));
WriteLn('B.X1 = ' + ToStr(B.X1));
WriteLn('B.Y1 = ' + ToStr(B.Y1));
WriteLn('B.X2 = ' + ToStr(B.X2));
WriteLn('B.Y2 = ' + ToStr(B.Y2));

b2 := (PointToBox(Point(000, 000), Point(111, 111)));

WriteLn(ToStr(b2));
WriteLn('b2.X1 = ' + ToStr(b2.X1));
WriteLn('b2.Y1 = ' + ToStr(b2.Y1));
WriteLn('b2.X2 = ' + ToStr(b2.X2));
WriteLn('b2.Y2 = ' + ToStr(b2.Y2));
end;

Is that what you are looking for? Excuse my lazy standards, please.

Dgby714

2012-01-12 22:28:19

From: RISK
Excuse my lazy standards, please.


I don't see anything wrong with it?

Press Play

2012-01-12 22:28:39

TBox is a type that actually contains 4 integers (that make up the 2 points):
From: Dgby714
Box.X1, Box.Y1, Box.X2, Box.Y2


In a similar way, the TPoint type can be converted in the same way:
Point.X, Point.Y

If you give some more information on what you're trying to do, I can help you further! :)

RISK

2012-01-12 22:30:08

I figured I could have made it shorter by making a loop for the WriteLns.

From: Dgby714
I don't see anything wrong with it?

m3gaman3g3nd

2012-01-12 22:51:39

well there are many useful functions like intTobox, or pointToBox. but what about the other way around?

RISK

2012-01-12 22:52:44

You just want the points of the box itself? Just use Box.X1, etc. Or what exactly are you trying to do?

m3gaman3g3nd

2012-01-12 22:59:58

im doing a whole lot but yes basically im searching a color and i did not have a way to make my box fit within the parameters ie. wrong variable type…

so b.x1 you say?

edit.
i would need the box ie. box1:Tbox to fit within findcolor(1111,box1.x1,box1.x2,box1.y1,box1.y2) i would not know if box.x1 changes a Tbox to an integer.

RISK

2012-01-12 23:10:59

procedure Exampe;
var
X, Y: Integer;
B: TBox;
begin
B := (IntToBox(100, 200, 300, 400));

if (FindColor(X, Y, COLOR, B.X1, B.Y1, B.X2, B.Y2)) then
WriteLn('Success.');
end;

How about like that? A TBox just holds 4 values to make a box. You can 'Grab' each of the values at any time you desire as long as you have the values declared. Like in the example script I have given you, you first declare the box's values and then you use the box's values in a FindColor() method. It's just 'Borrowing' the values from the TBox, really.

m3gaman3g3nd

2012-01-12 23:18:33

I appreciate your assistance and that is a prestige sample that clarifies everything, hail Hydra. Rep ++

edit.
ahhh but i see it must be x1 y1 x2 y2 or you get an error