Dear all, a new file comes under SRL's version control. (I say this because it was a pain in the butt figuring that I had to use svn 'add' rather than 'commit' through the terminal >.>)
PaintSmart.scar
http://villavu.com/repositories/srl-...aintSmart.scar
Simba Code:
//-----------------------------------------------------------------//
//-- Scar Standard Resource Library --//
//-- � Smart Painting routines --//
//-----------------------------------------------------------------//
// Procedure ClearCanvas(canvas: TCanvas; w, h: integer); //
// Procedure ClearRSCanvas(canvas: TCanvas); //
// Procedure SMART_DrawDotsEx(Clear: boolean; pixels: TPointArray; color: TColor);
// Procedure SMART_DrawDots(Dots: TPointArray); //
// Procedure SMART_DrawBoxEx(Clear: boolean; Box: TBox; color: TColor);
// procedure SMART_DrawBox(Box: TBox); //
//-----------------------------------------------------------------//
{*******************************************************************************
Procedure ClearCanvas(canvas: TCanvas; w, h: integer);
Contributors: Sir R. Magician, mastaraymond
Description: Clears a canvas of dimensions (w, h)
*******************************************************************************}
Procedure ClearCanvas(canvas: TCanvas; w, h: integer);
var
CleanBMP: integer;
begin
CleanBMP := BitmapFromString(w, h, '');
{$ifdef Simba}
DrawBitmap(CleanBMP,Canvas,0,0);
{$else}
SafeDrawBitmap(CleanBMP, canvas, 0, 0);
{$endif}
try
FreeBitmap(CleanBMP);
except end;
end;
{*******************************************************************************
Procedure ClearRSCanvas(canvas: TCanvas);
Contributors: Sir R. Magician
Description: Clears a canvas of RS dimensions
*******************************************************************************}
Procedure ClearRSCanvas(canvas: TCanvas);
begin
ClearCanvas(canvas, MIX2, MIY2);
end;
{*******************************************************************************
Procedure SMART_DrawDotsEx(Clear: boolean; pixels: TPointArray; color: TColor);
Contributors: Sir R. Magician, caused, mastaraymond
Description: Draws a TPA onto the SMART Debug canvas
*******************************************************************************}
procedure SMART_DrawDotsEx(Clear: boolean; pixels: TPointArray; color: TColor);
{$IFDEF SMART}
var
i : integer;
drawing : TBitmap;
begin
drawing := TBitmap.Create;
drawing.canvas.handle := SmartGetDebugDC;
drawing.canvas.Pen.Color := color;
ClearRSCanvas(drawing.canvas);
for i:= 0 to high(pixels) do
begin
drawing.canvas.moveto(pixels[i].x-1,pixels[i].y);
drawing.canvas.LineTo(pixels[i].x,pixels[i].y);
end;
try
FreeBitmap(drawing);
except end;
{$ELSE}
begin
{$ENDIF}
end;
{*******************************************************************************
Procedure SMART_DrawDots(Dots: TPointArray);
Contributors: Sir R. Magician
Description: Draws a TPA onto the SMART Debug canvas
*******************************************************************************}
procedure SMART_DrawDots(Dots: TPointArray);
begin
DrawDotsEx(True, Dots, clRed);
end;
{*******************************************************************************
procedure SMART_DrawBoxEx(Clear: boolean; Box: TBox; color: TColor);
Contributors: Sir R. Magician, caused, mastaraymond
Description: Draws a TBox onto the SMART Debug canvas
*******************************************************************************}
procedure SMART_DrawBoxEx(Clear: boolean; Box: TBox; color: TColor);
{$IFDEF SMART}
var
drawing : TBitmap;
TP : TPoint;
B: TBox;
begin
drawing := TBitmap.Create;
drawing.canvas.handle := SmartGetDebugDC;
drawing.canvas.Pen.Color := color;
ClearRSCanvas(drawing.canvas);
drawing.canvas.moveto(Box.x1,Box.y1);
drawing.canvas.LineTo(Box.x2,Box.y1);
drawing.canvas.LineTo(Box.x2,Box.y2);
drawing.canvas.LineTo(Box.x1,Box.y2);
drawing.canvas.LineTo(Box.x1,Box.y1);
try
FreeBitmap(drawing);
except end;
{$ELSE}
begin
{$ENDIF}
end;
{*******************************************************************************
Procedure SMART_DrawBox(Box: TBox);
Contributors: Sir R. Magician
Description: Draws a TBox onto the SMART Debug canvas
*******************************************************************************}
procedure SMART_DrawBox(Box: TBox);
begin
DrawBoxEx(True, Box, clRed);
end;
These functions allow you to debug things onto the Smart Debug. You'll have to turn it on once you load SMART. There's also a function for that, but I fail to remember which one atm.
Also, from experience, if you use this make a constant in your script to allow people to turn it off, if they so wish. Some computers might not be able to handle it properly (lagging) and some people might just not like it.
If anyone would like to write up functions to paint text or bitmaps onto the Smart Debug Canvas, go ahead.
~RM