Results 1 to 3 of 3

Thread: Help needed on drawing (filling) a rect!?

  1. #1

    Help needed on drawing (filling) a rect!?

    Hey...

    I'm having some troubles trying to draw a simple line!?

    Or maybe not that simple a line...

    I want to create a line, or it's probably more a rect that
    slowly gets filled with a solid color, and it should also be
    able to do a 90 degree corner.

    I could simple add a counter and then fill the rect a little
    more for each game loop, but then how can I make it turn?

    And ideas??

  2. #2

    Help needed on drawing (filling) a rect!?

    Hmm, it sounds like you want a multi-coloured selection rectangle using the mouse. Am I close to the mark?

    If that's what you want then here's some interesting bits and pieces:

    Creating a rubber-banding line - if you xor something, and then xor again with the same value, you'll get the original value. This has an important consequence: you can use the XOR copymode to draw your selection area once. When you need to erase it, you draw the same again - the line will be restored to the original image! You'd have to be careful to watch for drawing under a selection area first, of course - in which case, you'd have to get rid of the affected select first, change the pixel, and xor them again (otherwise the changing of pixel colours would fubar it all up).

    If you're redrawing the scene then it's even easier . Just draw the selection as normal and you won't have to erase it (only applicable if redrawing the scene every frame).

    Here's an article about rubber-banding over at Undo.com using the VCL

    You might also be interested in the "Marching Ants" algo. This is used to have your lines continually move around the selected area. One possible way to do this is with the LineDDA function (a bit slow, but usable nonetheless). That function lets you specify a callback for each pixel, which you can use to calculate whether to display this pixel.

    More info over at EFG: here

    EFG also has your multicoloured wish covered. Gradient lines. Here's another one that might potentially interest you: Line stretching

    If this doesn't suit your needs, could you be more specific please?
    "All paid jobs absorb and degrade the mind."
    <br />-- Aristotle

  3. #3

    Help needed on drawing (filling) a rect!?

    Thanks for the response...

    Anyway havn't had the time to check out the whole EFG yet, and I really don't know if I can use the Marching Ants...

    Anyway the function I want to create is something that is similiar to the function that is in "Pipe Mania" when the pipes get filled with water!...

    Pipe Mania, is a new edition of the good old "Pipe Dreams", anyway go to The Underdogs
    and grab your self a copy to see what I'm talking about. Btw the above link to a game called EmPipe, and it's freeware, maybe there are other clones of the Pipe games on The Underdogs.

    I hope that you know what function / effect that I'm talking about now.

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
  •