Results 1 to 15 of 15

Thread: SmartPaint.scar

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

    Default SmartPaint.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;

    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

    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
    Dec 2006
    Location
    Houston, TX USA
    Posts
    4,791
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    I like it

  3. #3
    Join Date
    Mar 2007
    Posts
    4,810
    Mentioned
    3 Post(s)
    Quoted
    3 Post(s)

    Default

    SCAR Code:
    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:

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

    I gather it could be like that?

    Looks nice

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

    Default

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

    Add to /misc/!

  5. #5
    Join Date
    Feb 2007
    Location
    Alberta,Canada
    Posts
    2,358
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    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.

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

    Default

    Quote Originally Posted by Blumblebee View Post
    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

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

  7. #7
    Join Date
    Feb 2007
    Location
    Alberta,Canada
    Posts
    2,358
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

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

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

    Default

    Quote Originally Posted by Blumblebee View Post
    SMART_DrawBox(P.x-10, P.y-10, etc);
    I meant, are you looping it?

    ~RM

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

  9. #9
    Join Date
    Nov 2009
    Location
    Seattle, WA
    Posts
    589
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    ^^ Beautiful job dude
    Don't Troll, Don't Fight, Just keep the Respect
    Status : Offline

    Feel free to re-make my scripts ;D
    Community Member

  10. #10
    Join Date
    Feb 2007
    Location
    Alberta,Canada
    Posts
    2,358
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by Sir R. Magician View Post
    I meant, are you looping it?

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

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

    no loop.

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

    Default

    Quote Originally Posted by Blumblebee View Post
    no, called it once. Made my TBox and then called it before the loop.

    SCAR Code:
    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

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

  12. #12
    Join Date
    Feb 2007
    Location
    Alberta,Canada
    Posts
    2,358
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by Sir R. Magician View Post
    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.

  13. #13
    Join Date
    Apr 2007
    Location
    Perth, Australia
    Posts
    3,926
    Mentioned
    3 Post(s)
    Quoted
    2 Post(s)

    Default

    How about some text drawing functions?

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

    Default

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

    ~RM

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

  15. #15
    Join Date
    Dec 2006
    Location
    Houston, TX USA
    Posts
    4,791
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    ClearRSCanvas doesn't work.

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
  •