SRL Archive - SRL Archives

SmartPaint.scar


Sir R. M8gic1an

2010-09-02 12:49:27


//-----------------------------------------------------------------//
//-- 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;

Got to the boring part of doing the headers :) Posting this just to have it posted somewhere >.>

There's an awful lot more things that could go into this, but i'll just get the ball rolling. :)

~RM

Wanted

2010-09-02 13:22:52

I like it

Naum

2010-09-02 13:54:45

  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);

To:

drawing.canvas.rectangle(Box.x1, Box.y1, Box.x2, Box.y2)

I gather it could be like that?

Looks nice :)

EvilChicken!

2010-09-02 17:20:25

Looking neat.
I gotta say, I love how you continuously come up with new stuff.

Add to /misc/!

Blumblebee

2010-09-02 17:21:44

It works well I just gave it a test run, however I found that it lagged my computer to hell when I used it. I dunno if that happens to anyone else, but just reporting.

Sir R. M8gic1an

2010-09-02 23:02:28

From: Blumblebee
It works well I just gave it a test run, however I found that it lagged my computer to hell when I used it. I dunno if that happens to anyone else, but just reporting.


How did you use it?

~RM

Blumblebee

2010-09-02 23:50:13

SMART_DrawBox(P.x-10, P.y-10, etc);

Sir R. M8gic1an

2010-09-03 00:30:31

From: Blumblebee
SMART_DrawBox(P.x-10, P.y-10, etc);


I meant, are you looping it?

~RM

Heavenguard

2010-09-03 01:38:02

^^ Beautiful job dude :D

Blumblebee

2010-09-03 02:30:57

From: Sir R. Magician
I meant, are you looping it?

~RM


no, called it once. Made my TBox and then called it before the loop.


P := TileToMS(tile(2477, 3419), 0);
SMART_DrawBox(P.x-10, etc);

no loop.

Sir R. M8gic1an

2010-09-03 02:41:58

From: Blumblebee
no, called it once. Made my TBox and then called it before the loop.


P := TileToMS(tile(2477, 3419), 0);
SMART_DrawBox(P.x-10, etc);

no loop.


Ok. Well, I see no reason for it to lag, I guess it'll depend on each person's computer and settings. Kinda sucks, but you can't have everything I guess.

~RM

Blumblebee

2010-09-03 03:03:51

From: Sir R. Magician
Ok. Well, I see no reason for it to lag, I guess it'll depend on each person's computer and settings. Kinda sucks, but you can't have everything I guess.

~RM


true true. It may have just been the circumstance I called it under, I'll do a few trials in different ways and let you know.

ZephyrsFury

2010-09-03 05:54:24

How about some text drawing functions? :)

Sir R. M8gic1an

2010-09-03 06:03:25

Not by me, but if someone wants to add them.. :rolleyes:

~RM

Wanted

2010-09-30 01:32:25

ClearRSCanvas doesn't work.