27
Virendra Singh Kushwah Assistant Professor Department of Computer Science

Polygon & Text Clipping

Embed Size (px)

Citation preview

Page 1: Polygon & Text Clipping

Virendra Singh KushwahAssistant Professor

Department of Computer Science

Page 2: Polygon & Text Clipping

A convex polygon will always have an interior angle with a measure that is less than 180 degrees.

Page 3: Polygon & Text Clipping

A concave polygon will always have an interior angle with a measure that is greater than 180 degrees.

Page 4: Polygon & Text Clipping
Page 5: Polygon & Text Clipping
Page 6: Polygon & Text Clipping

v1

v2v3

v1’

v2v3”

v1”

v3’

Note: Need to consider each of 4 edge boundaries

Page 7: Polygon & Text Clipping

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

Page 8: Polygon & Text Clipping

outside inside

v1v1’

v2

outside inside

v1

v2

outside inside

v1v1’

v2

outside inside

v1

v2

Outside to inside:Output: v1’ and v2

Inside to inside:Output: v2

Inside to outside:Output: v1’

Outside to outside:Output: nothing

Page 9: Polygon & Text Clipping

before clipping after clipping before clipping after clipping

Page 10: Polygon & Text Clipping
Page 11: Polygon & Text Clipping

original polygon left clip right clip bottom clip top clip

Page 12: Polygon & Text Clipping

D

S

S

DI

S

DD

S I

Save D.(a)

Save I.(b)

No PointsSaved.

(c)Save I and P.

(d)

Page 13: Polygon & Text Clipping

1

2

3

4

5

6

12

3

45

window

(a) (b)

window

Page 14: Polygon & Text Clipping

Similar methods as for lines and polygons but more processing is required due to non-linear equations.

For a curved object a bounding rectangle can be used to make a first test for overlap.

Page 15: Polygon & Text Clipping

before clipping

after clipping

Page 16: Polygon & Text Clipping

Line clipping using nonrectangular polygon clip windows◦ Convex polygon

Cyrus-Beck algorithm can be readily extended◦ Concave polygon

Split the concave polygon into convex polygons

Vector Method for Concave Splitting

• Calculate edge-vector cross products in a counterclockwise order

• If any z component turns out to be negative, the polygon is concave

Page 17: Polygon & Text Clipping

Polyline vs polygon fill-area

Early rejection is useful

Clipping Window

Bounding box of polygon fill area

Page 18: Polygon & Text Clipping

Clip against 4 infinite clip edges in succession

Page 19: Polygon & Text Clipping

Accept a series of vertices (polygon) and outputs another series of vertices

Four possible outputs

Page 20: Polygon & Text Clipping
Page 21: Polygon & Text Clipping

The algorithm correctly clips polygons, but may display extraneous lines for polygons

Page 22: Polygon & Text Clipping

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

Page 23: Polygon & Text Clipping

Polygon clipping using nonrectangular polygon clip windows

Page 24: Polygon & Text Clipping

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 string all-or-none character clipping

◦ use a bounding rectangle for the character individual character clipping

◦ like line/curve clipping (outlined char’s)◦ compare individual pixels (bit-mapped)

Page 25: Polygon & Text Clipping

All-or-none text clipping◦ Using boundary box for the entire text

All-or-non character clipping◦ Using boundary box for each individual

character Character clipping

◦ Vector font: Clip boundary polygons or curves

◦ Bitmap font: Clip individual pixels

Page 26: Polygon & Text Clipping
Page 27: Polygon & Text Clipping