Graphics Reference
In-Depth Information
Figure 3.23.
A Cyrus-Beck clipping example.
All-or-Nothing String Clipping. Here one computes the size of the rectangle that
contains the string and only maps the string to the frame buffer if the rectangle fits
entirely into the window in which the string is to be displayed.
All-or-Nothing Character Clipping. Here one clips on a character-by-character
basis. One computes the size of the rectangle that contains a given character and only
maps the character to the frame buffer if the rectangle fits entirely into the window
in which it is to be displayed.
The all-or-nothing approaches are easy to implement because it is easy to check
if one rectangle is inside another. The all-or-nothing character clipping approach is
often quite satisfactory. A more precise way to clip is to clip on the bit level. What
this means in the bit-mapped font case is that one clips the rectangular bitmap of
each character against the window rectangle and displays that part which is inside.
In the vector or outline font case, one would clip the curve that defines a character
against the window using one of the line-clipping algorithms and then scan converts
only the part of the character that lies in the window.
3.5
E XERCISES
Section 3.2.2.
3.2.2.1
Let p 1 = (-4,-2) and p 2 = (2,3). Let A = (0,0), B = (3,0), and C = (0,3). Work out the
steps of the Cyrus-Beck clipping algorithm and compute the [a i ,b i ]s that are generated
when clipping the segment [ p 1 , p 2 ] against triangle ABC . See Figure 3.23. Assume that
the lines L 1 , L 2 , and L 3 are defined by equations y = 0, x = 0, and x + y = 3, respectively.
3.6
P ROGRAMMING P ROJECTS
1.
Clipping (Section 3.3.5 and 3.3.6)
Implement either the Vatti or Greiner-Hormann clipping algorithm in such a way so that it
handles all three set operations «, », and -.
Search WWH ::




Custom Search