2D Thick Line Algorithm

Started by
15 comments, last by Plague1392 21 years, 7 months ago
Thick Line Drawing Algorithm I was working on a clone of Bust A Move and just had to change the targeting arrow from the GDI to something a bit faster. It worked nicely with the GDI using a 7 pixel thick line: I couldn’t find an algorithm to draw thick lines and couldn’t think of one myself that would allow me to end the line with a point, so I just drew seven lines next to each other with Bresenham’s algorithm. I did the code for the centre line and started it up and it looked fine: Then I rotated it and…oh dear: I think the gaps are to do with rounding when the line is rotated. I think the way I’ve implemented it is rather poor. Does anyone know where I can find an algorithm for drawing thick lines of a specified width? I’d be very grateful for any help you can offer. [edited by - plague1392 on August 18, 2002 4:17:36 PM]
Advertisement
Can''t you just draw a quad and or two triangles or more?
That was my backup plan I just think a thick line algorithm would be useful to know in the future, but I can''t seem to find one anywhere.
Rotate a sprite of the arrow, or a textured quad if you''re in 3D.

------------
- outRider -
Do it as a simplified form of polyfiller. That''s about the only way I can think of that solves the edge problem. I tried to code several thick-line routines over the years, but always failed to come up with a general rule of how the edges should be. If you had a good polyfiller, you could make a wrapper for each type of line edges you want.
Hmm... I also need a good thick line drawing algorithm. Anyone know a good reference? I STFW''ed but didnt find much.
Back in qbasic, I wrote a routine to draw a thick line pixel by pixel. It basically just a simple quad filler. You''ll have to calculate the min x and max x for each row of pixels in the quad, then draw horizontal lines between the points. Basically a simple quad filler.
lol
just use a bitmap with all the rotating frame.
it''s an animation of the rotation, not a calculation.
do you understand ??
i know that in bust a move, the rotating arrow is from 0 to Pi.
so store the rotating arrow animation from 0 to Pi step Angle and draw the corespondant frame.
I sorted it out last night, but I'm still very interested if anyone does have a link to an algorithm for drawing thick lines.

I probably shouldn't have asked the question specific to a problem because I could think of a number of ways to solve the specific problem, and was really just after the thick line drawing algorithm rather than suggested solutions. I mainly described the problem to show I had taken a shot at it myself and hadn't just come and posted here without trying myself first.

Anyway, thanks to everyone for putting the effort in to try and help me (well, everyone but the guy directly above). It's very much appreciated.


[edited by - plague1392 on August 19, 2002 9:26:37 AM]
Check your mail, Plague1392.

This topic is closed to new replies.

Advertisement