SRL Archive - FAQ

Painting on SMART Canvas?


Narcle

2010-06-17 07:10:32

More or less what title says. I've searched and searched but I haven't found nor figured out a way to paint to SMARTS debug canvas with Simba.

Anyone know how? (if it even exists right now)

Edit-
Figured it out. Thx Ray.

mastaraymond

2010-06-17 07:20:58


procedure DrawBitmap(Bmp: Integer; Dest: TCanvas; x, y: Integer);

Narcle

2010-06-17 07:28:39

Yes I know, tried that at least 50 times. There is no way to get the TCanvas of SMARTs DEbug for that to work. GetSmartDebugDC is not the same.

Wizzup?

2010-06-17 11:46:30

Perhaps post how you solved it?

Narcle

2010-06-17 11:48:13

From: Wizzup?
Perhaps post how you solved it?


no!

Edit: ok here

procedure PrintOnSmart(TP: TStringArray; Placement: TPoint; Colour, Shadow: integer);
var
mx, my, Pic, I, B, H, TPH, Numb: Integer;
TTP: TPointArray;
Canvas: TCanvas;
begin
SmartSetDebug(True);
GetClientDimensions(mx,my);
Pic := BitmapFromString(mx,my,'');
TPH := High(TP);
for I := 0 to TPH do
begin
TTP := LoadTextTPA(TP[i], UpChars, H);
for B := 0 to High(TTP) do
begin
Numb := ((I + 1) * 13);
FastSetPixel(Pic, TTP[b].x + 1, TTP[b].y + Numb + 1, Shadow);
FastSetPixel(Pic, TTP[b].x, TTP[b].y + Numb, Colour);
end;
end;
Canvas := TCANVAS.Create;
Canvas.Handle := SmartGetDebugDC;
DrawBitmap(Pic, Canvas, Placement.x, Placement.y);
FreeBitmap(Pic);
end;

edit 2: And debugging (very cool)
function DebugTPA(Points: TPointArray): Boolean;
var
Bmp: integer;
P: TPoint;
Canvas: TCanvas;
begin
GetClientDimensions(P.x, P.y);
bmp := BitmapFromString(P.x, P.y,'');
DrawTPABitmap(Bmp,Points,clRed);
Canvas := TCANVAS.Create;
Canvas.Handle := SmartGetDebugDC;
DrawBitmap(bmp, Canvas, 0, 0);
FreeBitmap(Bmp);
Result := True;
end;

function DebugATPA(Points: T2DPointArray): Boolean;
var
Bmp: integer;
P: TPoint;
Canvas: TCanvas;
begin
GetClientDimensions(P.x, P.y);
bmp := BitmapFromString(P.x, P.y,'');
DrawATPABitmap(bmp, Points);
Canvas := TCANVAS.Create;
Canvas.Handle := SmartGetDebugDC;
DrawBitmap(bmp, Canvas, 0, 0);
FreeBitmap(Bmp);
Result := True;
end;

Frement

2010-06-17 11:50:33

From: Narcle
no!

Edit: ok here

procedure PrintOnSmart(TP: TStringArray; Placement: TPoint; Colour, Shadow: integer);
var
mx, my, Pic, I, B, H, TPH, Numb: Integer;
TTP: TPointArray;
Canvas: TCanvas;
begin
SmartSetDebug(True);
GetClientDimensions(mx,my);
Pic := BitmapFromString(mx,my,'');
TPH := High(TP);
for I := 0 to TPH do
begin
TTP := LoadTextTPA(TP[i], UpChars, H);
for B := 0 to High(TTP) do
begin
Numb := ((I + 1) * 13);
FastSetPixel(Pic, TTP[b].x + 1, TTP[b].y + Numb + 1, Shadow);
FastSetPixel(Pic, TTP[b].x, TTP[b].y + Numb, Colour);
end;
end;
Canvas := TCANVAS.Create;
Canvas.Handle := SmartGetDebugDC;
DrawBitmap(Pic, Canvas, Placement.x, Placement.y);
FreeBitmap(Pic);
end;


So basicly the ProggyDebug() function someone posted :)?

Narcle

2010-06-17 11:52:53

From: Frement
So basicly the ProggyDebug() function someone posted :)?


yer, just copied it then changed what i needed. There actually is a faster way i believe using DrawTPA/ATPA but would have to offset the TString array. Could probably do it.

Edit: Like this

procedure PrintOnSmart(TP: TStringArray; Placement: TPoint; Colours: TIntegerArray);
var
x, y, bmp, I, B, H: Integer;
ATPA: T2DPointArray;
Canvas: TCanvas;
Colors: TIntegerArray;
begin
SmartSetDebug(True);
GetClientDimensions(x, y);
bmp := BitmapFromString(x, y, '');
SetArrayLength(ATPA, Length(TP));
for I := 0 to High(ATPA) do
begin
ATPA[i] := LoadTextTPA(TP[i], UpChars, H);
for B := 0 to High(ATPA[i]) do
ATPA[i][B].y := ATPA[i][B].y + i*(H);
end;
if Length(Colours) = 1 then
begin
SetArrayLength(Colors, Length(TP));
for i := 0 to High(Colors) do
Colors[i] := Colours[0];
end else
Colors := Colours;//colors, just to fuck with u
DrawATPABitmapEx(bmp, ATPA, Colors);
Canvas := TCANVAS.Create;
Canvas.Handle := SmartGetDebugDC;
DrawBitmap(bmp, Canvas, Placement.x, Placement.y);
FreeBitmap(bmp);
end;

//Try this for calling it

PrintOnSmart(['ooh test test', 'pretty colors', 'om nom nom', 'boredom sets in...'], Point(10, 10), [clRed, clBlue, clWhite, clYellow]);

Ogre

2010-06-17 15:37:52

Cool, I was wondering how you do this. :)

Sir R. M8gic1an

2010-07-12 17:48:42

We should get SmartPaint.scar .

There's an awful lot of these functions laying around. Your ATPA should also paint in different (preset?) colours ;)

~RM

BobboHobbo

2010-07-12 22:16:06

From: Rasta Magician
We should get SmartPaint.scar .

There's an awful lot of these functions laying around. Your ATPA should also paint in different (preset?) colours ;)

~RM


^ Like.

Wizzup?

2010-07-25 14:16:52

From: Rasta Magician
We should get SmartPaint.scar .

There's an awful lot of these functions laying around. Your ATPA should also paint in different (preset?) colours ;)

~RM


Good idea.