2D Thick Line Algorithm

Started by
15 comments, last by Plague1392 21 years, 8 months ago
i don''t know exactly but i think there is nothing like a thick line algorithm. actually you have only four possibilitis:

1. draw line beside line (what you already did)
2. draw a quad with lines and fill the quad (like prior suggested)
3. use a bitmap (like prior suggested) fix (from a file) and rotate
4. create a bitmap on the fly and calculate for every frame the points of the line (but that doesn''t make sense actually ;o))).
Advertisement
Alimonster sent me some information regarding the “moving pen” method of drawing lines, which seems a good solution because it allows for even thicknesses and does not produce the problem where the end of the line is horizontal (as happens if you set the pixels either side of a 1 pixel thick line).

I’ve been looking for a web site describing this method for anyone else who may be interested, but unfortunately the best I could find was:

http://fcggpc41.icg.tu-graz.ac.at/grabner/BACG_Online/node51.html

It’s not a great description but it may be useful.
this algorithm is probably too unefficient, but it can create very nice anti-aliased, thick lines.

for every pixel that could change colour after you draw your line (you could use a bounding box, or optimize it further by figuring out a smaller area), you check the closest distance to the line. if u just want a thick line, then change pixel colour to line colour if the distance is less than or equals to (line width * 0.5). if u want anti aliased line, then make it a smooth gradient or something. meaning the pixel colour will change colour closer to the line colour, depending on how far it is from the line. or you could use a sine wave here, to make the line bright in the center, and anti-aliased (more transparent) on the edges.

but like i said, that''s pretty unefficient. but i''m sure u could find great line drawing algorithms if you search google.com. good luck to you.

---
shurcool
wwdev
i think today''s ur lucky day!

well, i think i found something that may be of an interest to you. check this out!

hope that helps.

---
shurcool
wwdev
Jim Blinn''s got a nice book called "Dirty Pixels" which is a nice little 2d drawing algo book there are about 50 different circle drawing algos, among other things like line drawing algos. It''s a measely $19.99 and might be a worthy investment for problems like this.
quote:Original post by Anonymous Poster
Jim Blinn''s got a nice book called "Dirty Pixels" which is a nice little 2d drawing algo book there are about 50 different circle drawing algos, among other things like line drawing algos. It''s a measely $19.99 and might be a worthy investment for problems like this.


Actually that''s the wrong book sorry about that. The jim blinn book i was speaking of is "Jim Blinn''s Corner" Here is a link : http://www.amazon.com/exec/obidos/ASIN/1558603875/ref=pd_sr_ec_ir_b/102-5859057-5368901
bresenham thick line algorithm:

http://homepages.enterprise.net/murphy/thickline/

This topic is closed to new replies.

Advertisement