Polygon & Text Clipping
Polygon & Text Clipping
A convex polygon will always have an interior angle with a measure that is less than 180 degrees.
A concave polygon will always have an interior angle with a measure that is greater than 180 degrees.
v1
v1
v1 v3 v3
v2
v3
v2
Input each edge (vertex pair) successively. Output is a new list of vertices. Each edge goes through 4 clippers. The rule for each edge for each clipper is:
If first input vertex is outside, and second is inside, output the intersection and the second vertex If first both input vertices are inside, then just output second vertex If first input vertex is inside, and second is outside, output is the intersection If both vertices are outside, output is nothing
outside
inside v2
outside
inside v2
outside v2 v1
inside
outside v2
inside
v1
v1 v1
Inside to inside: Output: v2
v1
v1
Outside to outside: Output: nothing
before clipping
after clipping
before clipping
after clipping
original polygon
left clip
right clip
bottom clip
top clip
D
S
I
D
D
I
D
S
S
Save D. (a)
Save I. (b)
window
3
window
2 1
1
3
5
4
5
(a)
(b)
Similar methods as for lines and polygons but more processing is required due to nonlinear equations. For a curved object a bounding rectangle can be used to make a first test for overlap.
before clipping
after clipping
Concave polygon
Split the concave polygon into convex polygons
Accept a series of vertices (polygon) and outputs another series of vertices Four possible outputs
The algorithm correctly clips polygons, but may display extraneous lines for polygons
For an outside-to-inside pair of vertices, follow the polygon boundary For an inside-to-outside pair of vertices, follow the window boundary in a clockwise direction
In general, methods depend on how characters are represented However, three strategies can be followed: all-or-none string clipping
use a bounding rectangle for the character like line/curve clipping (outlined chars) compare individual pixels (bit-mapped)
Character clipping
Vector font: Clip boundary polygons or curves Bitmap font: Clip individual pixels