SRL Archive - Senior Scripts and Snippets

SmartDebugTPA/ATP


Bobarkinator

2008-03-04 19:44:37

These functions are based off of Wizzy's DebugTPA/ATPA, except they draw on the SMART canvas instead of to the debug box. They work exactly the same also. And please tell me if it could have been done shorter as I am not an expert on canvases. F12 to clear canvas.


Function SmartDebugTPA(TPA: TPointArray): Boolean;
Var
Client,Overwrite: TCanvas;
I,Clear: Integer;
Begin
Client:= GetBitmapCanvas(BitmapFromString(765,503,''));
Client.Handle:= SmartGetDebugDC;
For I:= 0 To High(TPA) Do
Client.Pixels[TPA[I].X, TPA[I].Y]:= clRed;
SmartSetDebug(True);
Repeat
Wait(1);
Until(IsFKeyDown(12));
Clear:= BitmapFromString(765,503,'');
FastDrawClear(Clear,0);
Overwrite:= GetBitmapCanvas(Clear);
CopyCanvas(Overwrite,Client,0,0,765,503,0,0,765,503);
Result:= True;
End;

Function DebugATPA(ATPA: T2DPointArray): Boolean;
Var
Client,Overwrite: TCanvas;
I,L,Col,Clear: Integer;
Begin
Client:= GetBitmapCanvas(BitmapFromString(765,503,''));
Client.Handle:= SmartGetDebugDC;
SmartSetDebug(True);
For I:= 0 To High(ATPA) Do
Begin
Col:= Random(16777215);
For L:= 0 To High(ATPA[I]) Do
Client.Pixels[ATPA[I][L].X, ATPA[I][L].Y]:= Col;
End;
Repeat
Wait(1);
Until(IsFKeyDown(12));
Clear:= BitmapFromString(765,503,'');
FastDrawClear(Clear,0);
Overwrite:= GetBitmapCanvas(Clear);
CopyCanvas(Overwrite,Client,0,0,765,503,0,0,765,503);
Result:= True;
End;

Wizzup?

2008-03-05 16:15:53

Is this only for Smart v2?
I'm not sure whether Smart v1 already had that debug option…

Markus

2008-03-05 16:16:21

From: Wizzup?
Is this only for Smart v2?
I'm not sure whether Smart v1 already had that debug option…


v1 didnt have it

Smartzkid

2008-03-05 20:56:16

Also keep in mind to only use whilst debugging - having the debug pane enabled greatly increases your CPU usage.

Bobarkinator

2008-03-05 21:49:57

From: Smartzkid
Also keep in mind to only use whilst debugging - having the debug pane enabled greatly increases your CPU usage.


It certainly does ;)