ran@doc.ic.ac.uk (Robert A Nicholls) (05/29/91)
Hi, What is the best (fastest) way of drawing a thick line between two points. The thick line should be drawn so that given a sequence of points to draw through, the joins between the line segments should not be too jagged. Pointers to PD code would be fine. Thanks, Bob.
davis@3d.enet.dec.com (Peter Davis) (05/29/91)
In article <1991May29.115821.28308@doc.ic.ac.uk>, ran@doc.ic.ac.uk (Robert A Nicholls) writes... > > What is the best (fastest) way of drawing a thick line between two points. >The thick line should be drawn so that given a sequence of points to draw >through, the joins between the line segments should not be too jagged. > In this case, best may not equal fastest. Probably the fastest way to do this is the "brush-trajectory" approach, aka, the "fat pixel" approach. All you do is scan convert the line, using Bresenham or the algorithm of your choice. Instead of writing a single pixel at each point, however, you write a block of pixels in the shape of a "brush" which you have defined. This can be done by a pixel copy from the brush definition to the pixel you're currently writing. Depending on the shape of your brush, however, this could give you some undesirable results. For example, using a square or rectangular brush, you'll find that diagonal lines are thicker than horizontal or vertical lines. Using a roughly circular brush, on the other hand, will give you uniform line thickness, but you won't get square corners if you're drawing a rectangle or square, for example. The PostScript model gives you lots of choices about treatment of line end caps and joins between segments of line strings. It's tricky to implement though. Probably the simplest thing to do is draw each line segment as a rectangle whose length, parallel to the line segment, is the length of the segment and whose width is the desired line width. Then the line caps and line joins can be added in as polygons. Note that if you need to use Xor writing (ie, each pixel "written" is just exclusive-or'ed with the value you're writing), implementation becomes considerably more complicated. That's because the simple implementation of either of these methods will involve writing some pixels more than once, and that means Xor'ing the Xor, which restores the original value. If this is a requirement, it might be simplest to draw the line into a separate bitmap somewhere and then 'or' that into the picture you're drawing. -pd
turk@Apple.COM (Ken "Turk" Turkowski) (05/31/91)
ran@doc.ic.ac.uk (Robert A Nicholls) writes: > What is the best (fastest) way of drawing a thick line between two points. >The thick line should be drawn so that given a sequence of points to draw >through, the joins between the line segments should not be too jagged. Have a polyline as the interface, and convert the whole thing into a concave polygon. -- Ken Turkowski @ Apple Computer, Inc., Cupertino, CA Internet: turk@apple.com Applelink: TURK UUCP: sun!apple!turk