SRL Archive - SRL Archives

TPAInversusBMP by n3ss3s


n3ss3s

2008-01-23 10:34:33

Okay, what it does is that lets say that you have

***-**
**–***
******

and now the "-" are the points of your TPA, this function makes the "*"'s the TPA.

Also works as gap finder :)

Uses a bitmap, 0 - 15 ms.

Bitmap and TPA ofc :)


Procedure TPAInversusBMP(Var TPA: TPointArray; x1, y1, x2, y2: Integer);

Var
Bmp, I, L, H: Integer;
nTPA: TPointArray;
Begin
H := GetClientWindowHandle;
Bmp := BitmapFromString(x2, y2, '');
L := High(TPA);
For I := 0 To L Do
SetPixel(bmp, TPA[i].x, TPA[i].y, 255);
SetTargetDC(GetBitmapDC(Bmp));
FindColorsTolerance(nTPA, 0, x1, y1, x2, y2, 0);
SetArrayLength(TPA, GetArrayLength(nTPA));
TPA := nTPA;
SetTargetDC(H);
End;


EDIT: NOW ALSO A NON BMP VERS :)


Function InversusTPA(TPA: TPointArray; x1, y1, x2, y2: Integer): TPointArray;

Var
B: Array of Array of Boolean;
L, I, Z: Integer;
Begin
SetArrayLength(Result, Max(x1, x2) * Max(y1, y2));
SetArrayLength(B, x2);
For I := 0 To X2 - 1 Do
SetArrayLength(B[i], y2);
L := High(TPA);
For I := 0 To L Do
B[TPA[i].x][TPA[i].y] := True;
L := High(B);
For W := x1 to x2 Do
For H := y1 To y2 Do
If Not B[W][H] Then
Begin
Result[z] := Point(W, H);
Z := Z + 1;
End;
SetArrayLength(Result, Z);
End;

Santa_Clause

2008-01-23 10:48:49

I don't get it. What is this useful for :confused:

n3ss3s

2008-01-23 10:50:55


Also works as gap finder



There are a lot more questionable things to be asking what they are useful for than this :p

Santa_Clause

2008-01-23 11:01:22

Oh, now I understand. Thanks for answering the question ;)

mastaraymond

2008-01-23 13:11:02

I think you should only post functions that actually make sense :rolleyes: (or make some kind of n3ss3s include and post that..)

n3ss3s

2008-01-23 13:44:17

(or make some kind of n3ss3s include and post that..)


full of non-sensemaking functions? :mad:

Though this one wasn't like… teh gunpowder..

Negaal

2008-01-23 14:00:48

Nice one…Even I can understand it…but I don't get whats gasp?
Well…one my idea is like that:
If you havent built following in
Then you use backcolor[like green grass, brown dirt], and then you have to search only from places where there are no grass and dirt…etc
I'm not sure only if it's faster:p

Nice job tough

n3ss3s

2008-01-23 14:06:12

hehe, yeah, except for that usually the environment doesn't differ from the object enough to use tols high enough :)

mastaraymond

2008-01-23 14:12:16

Your second function looks exactly like all mine functions :(

Negaal

2008-01-23 14:24:07

From: mastaraymond
Your second function looks exactly like all mine functions :(


Hes near reaching to 1337 with his IQ, so watch out…

mastaraymond

2008-01-23 14:31:31

From: Negaal
Hes near reaching to 1337 with his IQ, so watch out…


How can that be possible!!! *Takes some IQ Boosters*

n3ss3s

2008-01-24 08:14:08

Hehe, raymond is one of my code heroes, though maybe not a mod hero xD

mastaraymond

2008-01-24 09:32:02

From: n3ss3s
Hehe, raymond is one of my code heroes, though maybe not a mod hero xD
You sure about that.. It could work against you :rolleyes:

Psychor

2008-01-24 10:13:13

Also works as gap finder


So it would find a door opening, as that's a gap in the wall?

n3ss3s

2008-01-24 10:22:25

So it would find a door opening, as that's a gap in the wall?


Hehe, I would just find the door by its colours, the gap would be the whole mainscreen except for a wall :p