|
-
November 3rd, 2006, 02:05 AM
#6
Re: To draw THICK lines using Bresenham's Algorithm
 Originally Posted by Andrea_Rossini
good idea
with your method the start pos offset must be horizontal if deltaY > deltaX and being vertical when deltaY < deltaX ?
it would be cool to draw an half circle at the beginnig and one at the end, to make a nice pencil effect.  I love halfcircles 
One thing you might consider doing, assuming the endpoints are (x1,y1) and (x2,y2), and thickness 2*r:
1) Use the line direction to get the perpendicular direction. Call it Vperp = (vx,vy). Assume (vx,vy) is normalized.
2) Determine the half circle of radius r at point (x1,y1). You want to start tracking at (x1,y1) + r*(vx,vy) and end at (x1,y1) - r*(vx,vy).
3) Depending upon the direction of the line, calculate each pixel that's approximately on that circle. These are the new endpoints for your parallel Bresenham lines.
On a slightly alternative route, you might consider choosing the perpendicular direction (vx,vy) as above, and using Bresenham to first draw a line between (x1,y1) - r*(vx,vy) and (x1,y1) + r*(vx,vy). If you keep track of the pixel coordinates as you draw the short line, you'll have a whole series of new left endpoints for parallel Bresenham. Do the same thing along the right boundary. Since the two end lines are parallel, you should have an identical number of left and right endpoints. Now, do Bresenham between each of these pairs of endpoints. The result should be a series of parallel Bresenham lines in the original direction, going up to r above and r below. (i.e., with total thickness r.)
Lastly, you might consider drawing all these lines via Bresenham, and then using an anti-aliased line on the boundaries to smooth the thick line. 
-- Paul
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|