[comp.windows.x] X Pixelization Rules

graphics@jazz.rtp.dg.com (local graphics) (02/10/90)

Could someone please tell me where I can find a document describing
the X pixelization rules?  Better yet, could you send me a copy?

Thanks.

keith@EXPO.LCS.MIT.EDU (Keith Packard) (02/10/90)

> Could someone please tell me where I can find a document describing
> the X pixelization rules?  Better yet, could you send me a copy?

The X Protocol describes the pixelization rules in the section describing the
CreateGC request (page 399 in the red book) in both the subsection on widelines
and filled polygons.

Although several requests do not have explicit pixelization rules, the general
rule apply to all:

"A pixel is inside if the center point of the pixel is inside and the center
 point is not on the boundary.  If the center point is on the boundary, the
 pixel is inside if and only if the polygon interior is immediately to its right
 (x increasing direction).  Pixels with centers along a horizontal edge are a
 special case and are inside if and only if the polygon interior is immediately
 below (y increasing direction)."

For 'polygon', substitute your favorite X graphics object.

Most objects can be pixelated exactly by using integer arithmetic, three
objects cannot be:

	1)  Bevel joins.  The slope of a bevel is frequently irrational,
	    no adaptation of an integer algorithm is known which exactly
	    follows an irrationally sloped line.  I believe that a proof
	    could be given which would show that no algorithm could exist.

	2)  Incomplete Filled Arcs.  The non-elliptical faces have slopes
	    specified in degrees*64; this trancendential number suffers from
	    the same difficulty as Bevel joins.
	
	3)  Wide Elliptical Arcs.  The specification for these is
	    intractably complex; the solution to a seventh order polynomial
	    is needed to compute each scanline intersection.  Circular
	    arcs are a special case which can be computed with integer
	    arithmetic, except for joins and caps (which suffer from
	    the same fate as the non-elliptical faces of incomplete
	    filled arcs).

The internal faces of wide dashed lines are also not exactly computable, but
the protocol allows leeway there, refusing to insist on any particular
interpretation of dashing, making almost any pixelization valid.

The R4 sample implementation attempts to exactly pixelate all objects which
are exactly computable.  We believe that it is correct, but are unable to
validate any but a small number of hand-computed images.

Keith Packard
MIT X Consortium