Line algorithm for width > 1 pixel

Started by
5 comments, last by Cat 23 years, 6 months ago
Hi, I''m looking for an algorithm, probably similar to Bresenham''s, that will enable me to draw a line thicker than 1 pixel. I have the centre co-ordinate of each width edge which makes a straight centre line, plus the width itself. I was thinking of finding the vertices by taking the perpendicular line to the centre line but I can''t think of a way to simplify the calculations other than doing Bresenham''s 4 times (one for each edge) and then filling it in. Any ideas would be appreciated!! Thanks in advance, Cat
Advertisement
You are assuming a 2d line, right? So there''s no perspective change?
Well, in that case, you can draw a perpendicular line (i.e. the width) into a small buffer. Then, instead of drawing a pixel at each point of the main line, you would blit that pre-drawn perpendicular line to that point. And, in this case, just like with drawing normal one-pixel wide lines, you have to find all points along the line, not just the x values of each y value (as when scanlining).
I''m not sure if this would actually be faster, but it''s worth a try
Just a thought:
wouldn't blitting/drawing multiple lines next to each other produce pixel-artefacts where pixels are missed?

Not even a clue if this is right, let alone relevent, but there you go.

Waassaap!!

Edited by - mr_jrt on October 4, 2000 12:53:46 PM
Waassaap!!
The way they do it in Foley/vanDam is column replication.
Like this->

XX
XXXoo
XXoooXX
ooXXX
XX

Where circles are line... (very simple)

or for each pixel in line, instead draw a rectangle.

While drawing the line you could test pixels to make rounded/sloped edges.

I guess it depends what you want them to look like.
Damn, that wasn''t formated right at all...
Instead of drawing pixels, draw circles (non-filled). It of course will not be as fast as some other methods, but if you don''t need the speed (wait, what am i saying this is a *game* programming website...) it will work just as well.
farmersckn
Yesterday is the past, tomorrow is the future. Today is a gift, that is why we call it the present.
Thanks for everyone''s suggestions!!

I actually found an algorithm (Murphy''s algorithm) which is based on Bresenham''s but draws one perpendicular line (using Bresenham) for each pixel on the original line.

The problem with drawing a pre-defined perpendicular line is that the method of drawing the line does not necessarily remain constant as you move in one direction so you actually have to calculate the perp line at each pixel.

The algorithm for lines where DeltaX >DeltaY >0 can be found on the net. (www.homepages.enterprise.net/murphy/thickline/index.html)
All cases can be based on that.

Cat

This topic is closed to new replies.

Advertisement