Results 1 to 6 of 6

Thread: [Dev #596] PaintSmart.scar

  1. #1
    Join Date
    Jul 2007
    Location
    Right now? Chair.
    Posts
    8,488
    Mentioned
    3 Post(s)
    Quoted
    12 Post(s)

    Default [Dev #596] PaintSmart.scar

    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

    I & I know Zion. It is in the spirit, body and mind of every one of us
    RMouse(obj: TMSIObject): boolean;

  2. #2
    Join Date
    Jul 2007
    Location
    Norway.
    Posts
    1,938
    Mentioned
    3 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by Sir R. Magician View Post
    If anyone would like to write up functions to paint text or bitmaps onto the Smart Debug Canvas, go ahead.
    CreateTextFromTPA?

    But, nice, you committed it.

  3. #3
    Join Date
    Oct 2006
    Location
    finland, helsinki
    Posts
    2,501
    Mentioned
    3 Post(s)
    Quoted
    2 Post(s)

    Default

    SCAR Code:
    rocedure SMART_DrawText(x, y: Integer; font, Text: string);
    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_DrawDots(tpa);
    end;

    you need to edit some of the functions to make it work properly

    Code:
    • Narcle: I recall Jukka releasing a bunch of scripts like this before... Its how he rolls I think. rofl
    • Solarwind: Dude, you are like... t3h s3x.
    • Hy71194: JuKKa you're a machine! You released 3 scripts in 10 minutes! :O
    • benjaa: woah.... Jukka is the man Guildminer pwns all
    • NaumanAkhlaQ: And JuKKa Is my Her0!

  4. #4
    Join Date
    Jul 2007
    Location
    Right now? Chair.
    Posts
    8,488
    Mentioned
    3 Post(s)
    Quoted
    12 Post(s)

    Default

    Quote Originally Posted by JuKKa View Post
    you need to edit some of the functions to make it work properly
    What do you mean?

    ~RM

    I & I know Zion. It is in the spirit, body and mind of every one of us
    RMouse(obj: TMSIObject): boolean;

  5. #5
    Join Date
    Oct 2006
    Location
    finland, helsinki
    Posts
    2,501
    Mentioned
    3 Post(s)
    Quoted
    2 Post(s)

    Default

    It clears the canvas every time you draw a new line of text.

    Code:
    • Narcle: I recall Jukka releasing a bunch of scripts like this before... Its how he rolls I think. rofl
    • Solarwind: Dude, you are like... t3h s3x.
    • Hy71194: JuKKa you're a machine! You released 3 scripts in 10 minutes! :O
    • benjaa: woah.... Jukka is the man Guildminer pwns all
    • NaumanAkhlaQ: And JuKKa Is my Her0!

  6. #6
    Join Date
    Jul 2007
    Location
    Right now? Chair.
    Posts
    8,488
    Mentioned
    3 Post(s)
    Quoted
    12 Post(s)

    Default

    Simba Code:
    procedure SMART_DrawText(x, y: Integer; font, Text: string);
    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(false, tpa, clBlack);
    end;

    Fixed. DrawDotsEx has a 'clear' parameter.

    edit: actually the clear parameter isn't being used. Need to fix that.

    ~RM

    I & I know Zion. It is in the spirit, body and mind of every one of us
    RMouse(obj: TMSIObject): boolean;

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •