SRL Archive - OSR Help

[SIMBA] Drawing TPA's in the debug image form?


Drakan

2010-04-27 18:51:17

Hey I was wonderin if someone had the function to draw TPA's in the Debug Image Form in Simba. Thanks!

Frement

2010-04-27 18:56:54

Debug.scar? Doesnt srl work with simba?

Wanted

2010-04-27 19:07:48

{.Include SRL\SRL\Misc\DeBug.SCAR}
DeBugTPA(TPA, '');
DeBugATPA(ATPA, '');
DeBugATPA([TPA], '');
DeBugATPABounds(ATPA);
DeBugATPABounds([TPA]);

Wizzup?

2010-04-27 19:14:10

Better use {$I File.extension} than {.include File.EXTENSION}
And don't uppercase extensions when they aren't uppercased in the actual file name. ;)

Wanted

2010-04-27 19:16:05

From: Wizzup?
Better use {$I File.extension} than {.include File.EXTENSION}
And don't uppercase extensions when they aren't uppercased in the actual file name. ;)


It's an OCD code style thing, yea use {$ for simba

Wizzup?

2010-04-27 19:25:19

From: IceFire908
It's an OCD code style thing, yea use {$ for simba


OCD? As in Obsessive-compulsive disorder?
The extension should just match the file's extension because otherwise it won't even load on other OS'es like Mac and Linux, as those are case sensitive. :p

Drakan

2010-04-27 22:29:11

Ah thanks, I wasnt aware of debug.scar :P I have been out for over a year ;)

Neg_

2010-05-02 06:50:40

From wizzup,

[PHP]
Function DebugTPA(Points: TPointArray; BmpName: String): Boolean;

Var
Width, Height, ClientBMP, I : Integer;
xs, ys, xe, ye: Integer;

Begin
Try
Begin
xe := xs xor xs;
ye := ys xor ys;
xs := 1 shl 20;
ys := 1 shl 20;

For I := 0 To High(Points) Do
Begin
xs := Min(xs, Points.X);
ys := Min(ys, Points.Y);

xe := Max(xe, Points.X);
ye := Max(ye, Points.Y);
End;

Width := xe - xs;
Height := ye - ys;

DisplayDebugImgWindow(0, 0);
DisplayDebugImgWindow(Width, Height);
ClientBMP := BitmapFromString(Width, Height, '');

CopyClientToBitmap(ClientBMP, xs, ys, xe, ye);
For I := 0 To High(Points) Do
FastSetPixel(ClientBMP, Points.X - xs, Points.Y - ys, 255);
If BmpName <> '' Then
SaveBitmap(ClientBMP, ScriptPath + BmpName + '.bmp');
SafeDrawBitmap(ClientBMP, GetDebugCanvas, 0, 0);
DisplayDebugImgWindow(Width, Height);

FreeBitmap(ClientBMP);
End
Except
FreeBitmap(ClientBMP);
End;
Result := True;
End;

Function DebugATPA(aPoints: Array Of TPointArray; BmpName: String): Boolean;

Var
Width, Height, ClientBMP, I, L, C, Col: Integer;
xs, ys, xe, ye: Integer;
OuterPoints: TPointArray;

Begin
For I := 0 To High(aPoints) Do
L := L + Length(aPoints);
SetLength(OuterPoints, L + 1);
C := 0;
For I := 0 To High(aPoints) Do
For L := 0 To High(aPoints) Do
Begin
C := C + 1;
OuterPoints[C] := aPoints[L];
End;

Try
Begin
xe := xs xor xs;
ye := ys xor ys;
xs := 1 shl 20;
ys := 1 shl 20;

For I := 0 To High(OuterPoints) Do
Begin
xs := Min(xs, OuterPoints.X);
ys := Min(ys, OuterPoints.Y);

xe := Max(xe, OuterPoints.X);
ye := Max(ye, OuterPoints.Y);
End;

Width := xe - xs;
Height := ye - ys;

DisplayDebugImgWindow(0, 0);
DisplayDebugImgWindow(Width, Height);
ClientBMP := BitmapFromString(Width, Height, '');

CopyClientToBitmap(ClientBMP, xs, ys, xe, ye)
For I := 0 To High(aPoints) Do
Begin
Col := Random(16777215);
For L := 0 To High(aPoints) Do
FastSetPixel(ClientBMP, aPoints[L].X - xs, aPoints[L].Y - ys, Col);
End;

SafeDrawBitmap(ClientBMP, GetDebugCanvas, 0, 0);
DisplayDebugImgWindow(Width, Height);
If BmpName <> '' Then
SaveBitmap(ClientBMP, ScriptPath + BmpName + '.bmp');

FreeBitmap(ClientBMP);
End
Except
FreeBitmap(ClientBMP);
End;
Result := True;
End;
[/PHP]