(none) imager-devel
/ help / lists / applications / search /

anti-alias, fractional coordinates

From: Arnar Mar Hrafnkelsson (
Date: Sat 24 Feb 2001 - 07:10:15 UTC

  • Next message: Tony Cook: "Re: anti-alias, fractional coordinates"

    There is a little design thing that needs to be sorted out. That is the
    matter of coordinates.

    The most simple form of this question is:

    Should the line (10,10) -> (20,20) include the (20,20) point itself?

    If not then drawing (20,20) -> (10,10) is not the same as doing it in the
    other direction, which is a bit annoying.

    The same things extends to the case where you want to draw a box

    should the perimeter be include? some which?

    This however is only one half of the story the other comes in when you
    consider anti-aliasing and fractional coordinates.

    In that case the line from (0.0, 0.0) to (5.0, 5.0) only covers
    the pixels
    (0.0, 0.0) (1.0, 1.0) (2.0, 2.0) (3.0, 3.0) (4.0, 4.0)

    It's also consistent when you draw the other way from (5.0, 5.0) to
    (0.0, 0.0).

    But it's not really intuitive.

    Consider drawing from (2.0, 0.0) to (0.0, 2.0) It will go from the lower
    left corner (if we think of a regular coordinate system instead of the
    upside down coordinate system in Imager) of each pixel rather than from
    its center. One way to make it more natural might be to add (0.5, 0.5) to
    all offsets. So when you specify that you want a circle at (50.0, 50.0)
    that has radius 10.0. It will actually be placed at (50.5, 50.5).
    The question wether the radius should be adjusted is not very clear to me.
    Also in this scheme drawing a line from (0.0, 0.0) to (5.0, 5.0) would be
    drawn from (0.5, 0.5) to (5.5, 5.5). In antialiased mode this would make
    the ends a bit blurry. (Maybe a little test is in order).

    It would also mean that a box with edges would always have soft edges.

    How does one deal with endpoints in non antialized mode?

    This is what is going on inside my head right now. I'd like to hear your
    opinions, not just the programmers but the people who have ideas on the
    API to this (since it is mostly about comming up with an api where you
    don't constantly have to be making "off by one" corrections.