View Full Version : Help needed on drawing (filling) a rect!?
PeterFree8
05-02-2003, 02:37 PM
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??
Alimonster
05-02-2003, 07:45 PM
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 (http://www.undu.com/DN960901/00000007.htm) 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 (http://www.efg2.com/Lab/Library/Delphi/Graphics/Algorithms.htm#RubberBanding)
EFG also has your multicoloured wish covered. Gradient lines (http://www.efg2.com/Lab/Library/Delphi/Graphics/Color.htm#Lines). Here's another one that might potentially interest you: Line stretching (http://www.efg2.com/Lab/Graphics/LineStretch.htm)
If this doesn't suit your needs, could you be more specific please?
PeterFree8
07-02-2003, 08:20 AM
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 (http://www.the-underdogs.org/game.php?id=2298)
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 (http://www.the-underdogs.org).
I hope that you know what function / effect that I'm talking about now.
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.