polygon & text clipping

Post on 12-Sep-2014

186 Views

Category:

Documents

2 Downloads

Preview:

Click to see full reader

TRANSCRIPT

Virendra Singh KushwahAssistant Professor

Department of Computer Science

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

v2v3

v1’

v2v3”

v1”

v3’

Note: Need to consider each of 4 edge boundaries

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

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

before clipping after clipping before clipping after clipping

original polygon left clip right clip bottom clip top clip

D

S

S

DI

S

DD

S I

Save D.(a)

Save I.(b)

No PointsSaved.

(c)Save I and P.

(d)

1

2

3

4

5

6

12

3

45

window

(a) (b)

window

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.

before clipping

after 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

Polyline vs polygon fill-area

Early rejection is useful

Clipping Window

Bounding box of polygon fill area

Clip against 4 infinite clip edges in succession

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

Polygon clipping using nonrectangular polygon clip windows

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)

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

top related