#### Archived

This topic is now archived and is closed to further replies.

# Line algorithm for width > 1 pixel

This topic is 6492 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

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

##### Share on other sites
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

##### Share on other sites
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

##### Share on other sites
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.

##### Share on other sites
Damn, that wasn''t formated right at all...

##### Share on other sites
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

##### Share on other sites
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

1. 1
2. 2
Rutin
24
3. 3
4. 4
JoeJ
18
5. 5

• 14
• 17
• 11
• 11
• 9
• ### Forum Statistics

• Total Topics
631758
• Total Posts
3002155
×