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 SMART_DrawText(x, y: Integer; font, Text: string; Color:TColor);
//-----------------------------------------------------------------//
var
SMART_Canvas: TBitmap;
SMART_DebugSetup: Boolean;
procedure SMART_SetupDebug();
begin
//SmartSetDebug(True);
SMART_Canvas := TBitmap.Create;
SMART_Canvas.canvas.handle := SmartGetDebugDC;
SMART_DebugSetup := true;
end;
{*******************************************************************************
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
writeln('SMART BITMAP NOT FREED');
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 + 100, MIY2 + 100);
end;
{*******************************************************************************
Procedure SMART_DrawDotsEx(Clear: boolean; pixels: TPointArray; color: TColor);
Contributors: Sir R. Magician
Description: Draws an ATPA onto the SMART Debug canvas
*******************************************************************************}
procedure DrawDotsMulti(Clear: boolean; pixels : T2DPointArray);
{$IFDEF SMART}
var
i, h, color : integer;
begin
if (not SMART_DebugSetup) then
SMART_SetupDebug();
if Clear then ClearRSCanvas(SMART_Canvas.canvas);
for h := 0 to High(pixels) do
begin
color := h div 5 + h mod 5;
case color of
0 : SMART_Canvas.canvas.Pen.Color := clWhite;
1 : SMART_Canvas.canvas.Pen.Color := clYellow;
2 : SMART_Canvas.canvas.Pen.Color := clBlue;
3 : SMART_Canvas.canvas.Pen.Color := clLime;
4 : SMART_Canvas.canvas.Pen.Color := clGreen;
end;
for i:= 0 to High(pixels[h]) do
begin
SMART_Canvas.canvas.moveto(pixels[h][i].x-1, pixels[h][i].y);
SMART_Canvas.canvas.LineTo(pixels[h][i].x, pixels[h][i].y);
end;
end;
{$ELSE}
begin
{$ENDIF}
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;
begin
if (not SMART_DebugSetup) then
SMART_SetupDebug();
SMART_Canvas.canvas.Pen.Color := color;
if Clear then ClearRSCanvas(SMART_Canvas.canvas);
for i:= 0 to high(pixels) do
begin
SMART_Canvas.canvas.moveto(pixels[i].x-1,pixels[i].y);
SMART_Canvas.canvas.LineTo(pixels[i].x,pixels[i].y);
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
SMART_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}
begin
if (not SMART_DebugSetup) then
SMART_SetupDebug();
SMART_Canvas.canvas.Pen.Color := color;
if Clear then ClearRSCanvas(SMART_Canvas.canvas);
SMART_Canvas.canvas.moveto(Box.x1,Box.y1);
SMART_Canvas.canvas.LineTo(Box.x2,Box.y1);
SMART_Canvas.canvas.LineTo(Box.x2,Box.y2);
SMART_Canvas.canvas.LineTo(Box.x1,Box.y2);
SMART_Canvas.canvas.LineTo(Box.x1,Box.y1);
{$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
SMART_DrawBoxEx(True, Box, clRed);
end;
{*******************************************************************************
procedure SMART_DrawTextEx(Clear: Boolean; x, y: Integer; font, Text: string; Color: TColor);
Contributors: Jukka, Shuttleu
Description: Draws text onto the SMART Debug canvas at position x, y
*******************************************************************************}
procedure SMART_DrawTextEx(Clear: Boolean; x, y: Integer; font, Text: string; Color:TColor);
var
i, height: integer;
tpa: tpointarray;
begin
tpa := LoadTextTPA(text,font,height);
for i:= 0 to high(tpa) do
begin
tpa[i].x := tpa[i].x + x;
tpa[i].y := tpa[i].y + y;
end;
SMART_DrawDotsEx(Clear, tpa, Color);
end;
{*******************************************************************************
procedure SMART_DrawText(x, y: Integer; font, Text: string; Color: TColor);
Contributors: Shuttleu
Description: Draws text onto the SMART Debug canvas at position x, y
*******************************************************************************}
procedure SMART_DrawText(x, y: Integer; font, Text: string; Color:TColor);
begin
SMART_DrawTextEx(False, x, y, font, Text, Color);
end;
procedure SMART_FreeDebug();
begin
try
SMART_Canvas.Free;
except
Writeln('Failed to free SMART_Canvas bitmap: '+ExceptionToString(ExceptionType, ExceptionParam));
end;
end;
Thanks in advance.