Welcome to Scribd, the world's digital library. Read, publish, and share books and documents. See more
Download
Standard view
Full view
of .
Save to My Library
Look up keyword
Like this
5Activity
0 of .
Results for:
No results containing your search query
P. 1
computer notes Filled Area Primitives I

computer notes Filled Area Primitives I

Ratings: (0)|Views: 2,782|Likes:
Published by ecomputernotes
Computer Graphics (ecomputernotes.com)
http://ecomputernotes.com - Computer Notes on Object orient Programming What is How Use it Explain with Example.
Filled-Area Primitives-I

So far we have covered some output primitives that is drawing primitives like point, line, circle, ellipse and some other variations of curves. Also we can draw certain other shapes with the combinations of lines like triangle, rectangle, square and other polygons (we will have some discussion on polygons coming ahead). Also we can draw some shapes using mixture of lines and curves or circles etc. So we are able to draw outline/ s
Computer Graphics (ecomputernotes.com)
http://ecomputernotes.com - Computer Notes on Object orient Programming What is How Use it Explain with Example.
Filled-Area Primitives-I

So far we have covered some output primitives that is drawing primitives like point, line, circle, ellipse and some other variations of curves. Also we can draw certain other shapes with the combinations of lines like triangle, rectangle, square and other polygons (we will have some discussion on polygons coming ahead). Also we can draw some shapes using mixture of lines and curves or circles etc. So we are able to draw outline/ s

More info:

Published by: ecomputernotes on Dec 23, 2011
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as DOC, PDF, TXT or read online from Scribd
See more
See less

12/03/2012

pdf

text

original

 
Computer Graphics (ecomputernotes.com)
Filled-Area Primitives-I
So far we have covered some output primitives that is drawing primitives likepoint, line, circle, ellipse and some other variations of curves. Also we can drawcertain other shapes with the combinations of lines like triangle, rectangle,square and other polygons (we will have some discussion on polygons comingahead). Also we can draw some shapes using mixture of lines and curves or circles etc. So we are able to draw outline/ sketch of certain models but need isthere to make a solid model.Therefore, in this section we will see what are filled area primitives and what arethe different issues related to them. There are two basic approaches to areafilling on raster systems. One way is to draw straight lines between the edges of polygon called
scan-line polygon filling
. As said earlier there are several issuesrelated to scan line polygon, which we will discuss in detail. Second way is tostart from an interior point and paint outward from this point till we reach theboundary called
boundary-fill
. A slight variation of this technique is used to fillan area specified by cluster (having no specific boundary). The technique iscalled
flood-fill
and having almost same strategy that is to start from an interior point and start painting outward from this point till the end of cluster.Now having an idea we will try to see each of these one by one, starting fromscan-line polygon filling.
8.1Scan-line Polygon Fill
Before we actually start discussion on scan-line polygon filling technique, it isuseful to discuss what is polygon? Besides polygon definition we will discuss thefollowing topics one by one to have a good understanding of the concept and itsimplementation.
Polygon Definition
Filled vs. Unfilled Polygons
Parity Definition
Scan-Line Polygon Fill Algorithm
Special Cases Handled By the Fill
Polygon Fill Example
a) Polygon
81
 
Computer Graphics (ecomputernotes.com)
A
polygon
can be defined as a shape that is formed by line segments that are
placed end to end, creating a continuous closed path. Polygons can be divided
into three basic types:
convex
,
concave
, and
complex
.I.
Convex
polygons are the simplest type of polygon to fill. Todetermine whether or not a polygon is convex, ask the followingquestion:Does a straight line connecting ANY two points that are inside the polygonintersect any edges of the polygon?If the answer is no, the polygon is convex. This means that for any scan-line, thescan-line will cross at most two polygon edges (not counting any horizontaledges). Convex polygon edges also do not intersect each other.II.
Concave
polygons are a superset of convex polygons, havingfewer restrictions than convex polygons. The line connecting anytwo points that lie inside the polygon may intersect more than twoedges of the polygon. Thus, more than two edges may intersectany scan line that passes through the polygon. The polygonedges may also touch each other, but they may not cross oneanother.
Complex
polygons are just what their name suggests: complex. Complexpolygons are basically concave polygons that may have self-intersecting edges.The complexity arises from distinguishing which side is inside the polygon whenfilling it.
82
 
)
 
Computer Graphics (ecomputernotes.com)
Difference between Filled and Unfilled Polygon
When an unfilled polygon is rendered, only the points on the perimeter of thepolygon are drawn. Examples of unfilled polygons are shown in the next page.However, when a polygon is filled, the interior of the polygon must be considered.All of the pixels within the boundaries of the polygon must be set to the specifiedcolor or pattern. Here, we deal only with solid colors. The following figure showsthe difference between filled and unfilled polygons.In order to determine which pixels are inside the polygon, the odd-parity rule isused within the scan-line polygon fill algorithm. This is discussed next.
b) Parity
What is parity?
Parity
is a concept used to determine which pixels lie within apolygon, i.e. which pixels should be filled for a given polygon.The Underlying Principle: Conceptually, the odd parity test entails drawing a linesegment from any point that lies outside the polygon to a point P, that we wish todetermine whether it is inside or outside of the polygon. Count the number of edges that the line crosses. If the number of polygon edges crossed is
odd
, then
P lies within the polygon. Similarly, if the number of edges is even, then P lies
outside of the polygon. There are special ways of counting the edges when theline crosses a vertex. This will be discussed in the algorithm section. Examples of counting parity can be seen in the following demonstration.
83
(ecomputernotes.com)

Activity (5)

You've already reviewed this. Edit your review.
1 hundred reads
1 thousand reads
紀崇楠 liked this
Desu Habtish liked this
Nagarjuna Gutta liked this

You're Reading a Free Preview

Download
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->