Page 96 Table of Contents Index Page 98
Chapters
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30
A, B, C, D, E



CHAPTER 12. GRAPHICS


Figure 12.1: Pixel assignment with boundary on decision points.

It is important to note that these rules imply that the decision point used for insideness checking
is offset from the point used for addressing the pixel by half a device unit in both the x and y
directions. It is worth considering the motivations for these conventions.

When two shapes share a common edge, it is important that only one of the shapes own any
pixel. The two triangles in Figure 12.1 illustrate this. The pixels along the diagonal belong to
the lower figure. When the decision point of the pixel (its center) lies to one side of the line or
the other, there is no issue. When the boundary passes through a decision point, which side the
inside of the figure is on is used to decide. These are the triangles that CLIM implementations
should attempt to draw in this case.

The reason for choosing the decision point half a pixel offset from the address point is to reduce
the number of common figures (such as rectilinear lines and rectangles with integral coordinates)
that invoke the boundary condition rule. This usually leads to more symmetrical results. For
instance, in Figure 12.2, we see a circle drawn when the decision point is the same as the address
point. The four lighter points are indeterminate: it is not clear whether they are inside or outside
the shape. Since we want to have each boundary case determined according to which side has
the figure on it, and since we must apply the same rule uniformly for all figures, we have no
choice but to pick only two of the four points, leading to an undesirable lopsided figure.

If we had instead chosen to take all four boundary points, we would have a nice symmetrical
figure. However, since this figure is symmetrical about a whole pixel, it is one pixel wider than
it ought to be. The problem with this can be seen clearly in Figure 12.3 if we attempt to draw
a rectangle and circle overlaid with the following code:

 
 (defun draw-test (sheet radius)
   (draw-circle* sheet 0 0 radius :ink +foreground-ink+)
   (draw-rectangle* sheet (- radius) (- radius) (+ radius) (+ radius)
                    :ink +flipping-ink+))
It is for this reason that we choose to have the decision point at the center of the pixel. This
draws circles that look like the one in Figure 12.4. It is this shape that CLIM implementations


Page 96 Table of Contents Index Page 98
Chapters
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30
A, B, C, D, E