Results 1 to 10 of 27

Thread: BGRABitmap tutorial

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Co-Founder / PGD Elder WILL's Avatar
    Join Date
    Apr 2003
    Location
    Canada
    Posts
    6,107
    Blog Entries
    25
    I was wondering about a water or ocean type effect on the background of the form or something like that. I think I know what the answer might be though.
    Jason McMillen
    Pascal Game Development
    Co-Founder





  2. #2
    Quote Originally Posted by chronozphere View Post
    I'd like to play with this, but the FPC wiki seems to be down.
    Yes, unfortunately. You can still have a look at the bgrafunctest folder in LazPaint archive. You can find it here :
    http://sourceforge.net/projects/lazpaint/files/src/

    Quote Originally Posted by WILL View Post
    I was wondering about a water or ocean type effect on the background of the form or something like that. I think I know what the answer might be though.
    Well, it depends. You can precalculate an ocean texture. Then, just showing it is ok. But if you want to animate it, well, it would be too slow, except maybe with a very small texture.
    Last edited by circular; 09-04-2011 at 08:11 AM. Reason: link

  3. #3
    Thanks. How can I install that lpk package? Can I move my source files after I have installed the package? (Really annoying that I have to ask this, because all the documentation for lazarus is inaccessible. )

    Update: It seems like they have fixed the problem.
    Last edited by chronozphere; 09-04-2011 at 04:13 PM.
    Coders rule nr 1: Face ur bugz.. dont cage them with code, kill'em with ur cursor.

  4. #4
    Once the package is installed, you need to specify package dependency in the project inspector. Then you can move your project whereever you want.

  5. #5
    I have a little problem. I want to draw a closed polygon, but it doesn't work:

    Code:
    var
      image: TBGRABitmap;
      storedSpline: array of TPointF;
      c: TBGRAPixel;
    begin
      image := TBGRABitmap.Create(ClientWidth,ClientHeight,ColorToBGRA(ColorToRGB(clBtnFace)));
      c := ColorToBGRA(ColorToRGB(clWindowText));
    
      setLength(storedSpline, 3);
      storedSpline[0].x := 50;
      storedSpline[0].y := 50;
      storedSpline[1].x := 100;
      storedSpline[1].y := 100;
      storedSpline[2].x := 0;
      storedSpline[2].y := 100;
    
      image.DrawPolylineAntialias(storedSpline,c,1, true); //This call should draw a closed spline
    
      image.Draw(Canvas,0,0,True);
      image.free;
    end;
    The last parameter is called Closed, so I presume that when I pass true, I will get a closed spline, but It's still open.
    Anybody?
    Coders rule nr 1: Face ur bugz.. dont cage them with code, kill'em with ur cursor.

  6. #6
    It's normal. A polyline is not a closed figure. The closed parameter means that the end of the segment is closed. See here :
    http://wiki.lazarus.freepascal.org/B...map_tutorial_6

    If you want to draw a closed path, then use DrawPolygonAntialias.

    By the way, naming a variable storedSpline does not automatically create a spline. You need to call ComputeClosedSpline. See here :
    http://wiki.lazarus.freepascal.org/B...map_tutorial_7

    If you feel the tutorial is ambiguous somewhere, please tell me what you suggest to add or change.
    Last edited by circular; 09-04-2011 at 10:22 PM. Reason: spline

  7. #7
    Thanks! It works great now.

    By the way, naming a variable storedSpline does not automatically create a spline. You need to call ComputeClosedSpline. See here :
    Don't pay attention to that name. I was reusing that name from another piece of code that did use a spline.
    Coders rule nr 1: Face ur bugz.. dont cage them with code, kill'em with ur cursor.

Tags for this Thread

Bookmarks

Posting Permissions

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