[comp.graphics] thick lines, circles and ellipses

ingwa@prefix.liu.se (Inge Wallin) (01/07/88)

The current disussion about circles made me think about something else
in the same genre. How do you, efficiently, draw lines, arcs, circles
and so on with a line width bigger than 1?

Although I have read many articles about fast line and circle drawing
algorithms, I have never seen anything about thicker ones.  Neither
have I seen any algorithms in any computer graphics books. I find this
a bit strange since such algorithms seem to me to be very important.
An obvious example is in a laser printer.

Could somebody please explain how this is done, or give me some
pointer to where I can find the information?

                             ADVAthanksNCE
                             /Inge Wallin

                             mail address: ingwa@majestix.liu.se

nelson@sun.soe.clarkson.edu (Russ Nelson) (01/08/88)

In article <694@prefix.liu.se> ingwa@prefix.liu.se (Inge Wallin) writes:
>The current disussion about circles made me think about something else
>in the same genre. How do you, efficiently, draw lines, arcs, circles
>and so on with a line width bigger than 1?

The typical technique is to generate a stream of pixels and run them
through a routine that plops (it's a technical term that means to OR or
AND NOT a specific shape) something down.  In Painter's Apprentice (A
soon to be released paint package for the PC's EGA <shameless self
promotion>), I have a VERY efficient routine to plop a 16x16 bit shape
down.  For example, the code is split into the following cases:
	clipped/non-clipped
	16 bits wide/24 bit wide
	OR/AND NOT/other
	I also pre-shift 8 different copies of the shape, one for each
	different byte boundary.  (Oh, for a barrel shifter!).

I use this code even though I have a "Chris Pike" style compiling blit.

For obvious reasons, the speed of this code dominates the line drawing speed.
Every cycle you can save in this routine will be amply repaid.
-russ

kgdykes@watmath.waterloo.edu (Ken Dykes) (01/10/88)

In article <694@prefix.liu.se> ingwa@prefix.liu.se (Inge Wallin) writes:
>in the same genre. How do you, efficiently, draw lines, arcs, circles
>and so on with a line width bigger than 1?
>
>Although I have read many articles about fast line and circle drawing
>algorithms, I have never seen anything about thicker ones.  Neither
>have I seen any algorithms in any computer graphics books. I find this
>a bit strange since such algorithms seem to me to be very important.
>An obvious example is in a laser printer.
>
>                             /Inge Wallin
 I myself a few years ago during a night decided that i needed to do
this in some page-printer software i was doing.
Not having taken any graphics courses, and not having a reference
library on-site where i was working, i ended up doing the obvious
"concentric circles" (you now, plotting N circles simultaneously where
 N=thickness)
this hack has bothered me ever since everytime i think about this
software.
in the next few months i may be getting an opportunity to revise this
program so i too would appreciate info/references. (especially ones
that dont assume a graduate degree in computer graphics)
(ps: i wont mention that even for "simple" circle drawing i suspect
 that i used the most brain-damaged childs algorithm one can dream
 up with no sleep).
[and if it turns out that i *am* using the most optimal way for what
 i need -- i will loose all faith in the mystery of computer science! :-]
         -ken
-- 
          - Ken Dykes,   Software Development Group, U.of.Waterloo
              kgdykes@watmath.uucp     kgdykes@water.bitnet
              kgdykes@waterloo.csnet

holloway@drivax.UUCP (Bruce Holloway) (01/12/88)

In article <694@prefix.liu.se> ingwa@prefix.liu.se (Inge Wallin) writes:
>The current disussion about circles made me think about something else
>in the same genre. How do you, efficiently, draw lines, arcs, circles
>and so on with a line width bigger than 1?

We do it by drawing a rectangle with the desired width, the same direction
as the line. This makes patterned lines (-.-.-., etc.) difficult, so we
don't do 'em.

- Bruce
-- 
*******************************************************************************
* Bruce Holloway - Terminal Netnews Addict       uunet!amdahl!drivax!holloway *
* ALBATROSS, ATARI*TROS @ Plink                            ALBATROSS @ Delphi *
*******************************************************************************

kjepo@portofix.liu.se (Kjell Post) (01/12/88)

In article <16183@watmath.waterloo.edu>, kgdykes@watmath.waterloo.edu (Ken Dykes) writes:
> In article <694@prefix.liu.se> ingwa@prefix.liu.se (Inge Wallin) writes:
> >in the same genre. How do you, efficiently, draw lines, arcs, circles
> >and so on with a line width bigger than 1?

Why not use a thicker pencil?

What I'm saying is that you can print a larger dot instead of just a pixel.
This is the method used by ditroff where they draw lines, arcs and b-splines
with the '.' character. By altering the fontsize you get different line widths.



-- 
-----------------------------------------------------------------------------
"The nice thing about standards is that you have so many to choose from"
Dept of Computer & Info Science  ...liuida!majestix.liu.se!kjepo
Univ of Linkoping, Sweden        (kjepo@majestix.liu.se)

johng@ecrcvax.UUCP (John Gregor) (01/17/88)

In article <696@portofix.liu.se> kjepo@portofix.liu.se (Kjell Post) writes:
>Why not use a thicker pencil?
>
>What I'm saying is that you can print a larger dot instead of just a pixel.
>This is the method used by ditroff where they draw lines, arcs and b-splines
>with the '.' character. By altering the fontsize you get different line widths.

That may be fine for output to a laser printer, but it is extremely inefficient
for any sort of interactive graphics.  Here is an example:

Assume your big dot is:          ##
				####
Also assuming square pixels     ####
				 ##

Then drawing a line (slope == 1) would look like:

	     11
            2211
           23221
	  23232       The numbers correspond to the number of times the 
	 12232        pixel is written.
	 1122
	  11

Even though there is a fix for lines, this scheme is completely impractical
for curves.  I recommend scan converting the polygon.

				John Gregor
                      johng%ecrcvax.UUCP@germany.CSNET

kjepo@prefix.liu.se (Kjell Post) (01/19/88)

In article <471@ecrcvax.UUCP> johng@ecrcvax.UUCP (John Gregor) writes:
>In article <696@portofix.liu.se> kjepo@portofix.liu.se (Kjell Post) writes:
>>Why not use a thicker pencil?
>Even though there is a fix for lines, this scheme is completely impractical
>for curves.  I recommend scan converting the polygon.
>
>				John Gregor
>                      johng%ecrcvax.UUCP@germany.CSNET

I wouldn't be too sure about that. Some of the modern graphic processors
can bitblt a pattern as fast as they set pixels.


-- 
-----------------------------------------------------------------------------
"The nice thing about standards is that you have so many to choose from"
Dept of Computer & Info Science  ...liuida!majestix.liu.se!kjepo
Univ of Linkoping, Sweden        (kjepo@majestix.liu.se)

rmf@actnyc.UUCP (Robert Fuhrer) (01/29/88)

This is my first posting, so I respectfully request no flames please if the
following does not represent the optimal (or even a working) solution:

Well, it seems to me that, especially in the case where the pen's "footprint" is
larger than 1x1, and is a pattern, e.g., a grey pattern of alternating white &
black pixels, you CAN do something:

Suppose, when drawing a line and incrementing in the vertical coordinate
(similar concept applies when incrementing the horizontal of course), that you
draw successive 1-pixel-high horizontal bands from your pattern.

When drawing conics, corners may require special treatment (such as plotting the
entire pen's footprint when changing from incrementing x to incrementing y?),
but I think the general approach works.

Comments, anyone? Am I on the right trail?

* No snappy sign-off *