#603425 libcaca0: caca_draw_ellipse() pixels

Package:
libcaca0
Source:
libcaca
Description:
colour ASCII art library
Submitter:
Kevin Ryde
Date:
2014-06-30 22:09:36 UTC
Severity:
normal
#603425#5
Date:
2010-11-13 23:49:04 UTC
From:
To:
Running the foo.c below prints an ellipse like

     *****
     *   *
    *     *
    *     *
    *     *
     *   *
     *****

where I hoped it might look like

      ***
     *   *
    *     *
    *     *
    *     *
     *   *
      ***

which doesn't have the square corners top and bottom, and is symmetric
vertically and horizontally.  Some other sizes have a few doubtful
looking pixels, but this is probably the most obvious.

Nosing around the code, it's possible the +3 from the computer graphics
book might be right.  I think the step is supposed to maintain

    d1 == (x+1)^2*b^2 + (y-1/2)^2*a^2 - a^2*b^2

or something like that, if chucking in a debug assertion helped.  Does
+1 or +3 depend whether the x++ increment is before or after the d1
step, maybe?

Incidentally, in the d1>=0 case is "2*x*1" meant to be "2*x+1"?