- 233 Views
- Uploaded on
- Presentation posted in: General

2D Output Primitives

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.

- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -

**1. **2D Output Primitives Points
Lines
Circles
Ellipses
Other curves
Filling areas
Text
Patterns
Polymarkers

**2. **Filling area Polygons are considered!
Scan-Line Filling (between edges)
Interactive Filling (using an interior starting point)

**3. **1) Scan-Line Filling (scan conversion)
Problem: Given the vertices or edges of a polygon, which are the pixels to be included in the area filling?

**4. **Scan-Line filling, cont’d Main idea:
locate the intersections between the scan-lines and the edges of the polygon
sort the intersection points on each scan-line on increasing x-coordinates
generate frame-buffer positions along the current scan-line between pairwise intersection points

**5. **Main idea

**6. **Scan-Line filling, cont’d Problems with intersection points that are vertices:
Basic rule: count them as if each vertex is being two points (one to each of the two joining edges in the vertex)
Exception: if the two edges joining in the vertex are on opposite sides of the scan-line, then count the vertex only once (require some additional processing)

**7. **Vertex problem

**8. **Scan-Line filling, cont’d Time-consuming to locate the intersection points!
If an edge is crossed by a scan-line, most probably also the next scan-line will cross it (the use of coherence properties)

**9. **Scan-Line filling, cont’d Each edge is well described by an edge-record:
ymax
x0 (initially the x related to ymin)
?x/?y (inverse of the slope)
(possibly also ?x and ?y)
?x/?y is used for incremental calculations of the intersection points

**10. **Edge Records

**11. **Scan-Line filling, cont’d The intersection point (xn,yn) between an edge and scan-line yn follows from the line equation of the edge:
yn = ?y/?x . xn + b (cp. y = m.x + b)
The intersection between the same edge and the next scan-line yn+1 is then given from the following:
yn+1 = ?y/?x . xn+1 + b
and also
yn+1 = yn + 1 = ?y/?x . xn + b +1

**12. **Scan-Line filling, cont’d This gives us:
xn+1 = xn + ?x/?y , n = 0, 1, 2, …..
i.e. the new value of x on the next scan-line is given by adding the inverse of the slope to the current value of x

**13. **Scan-Line filling, cont’d An active list of edge records intersecting with the current scan-line is sorted on increasing x-coordinates
The polygon pixels that are written in the frame buffer are those which are calculated to be on the current scan-line between pairwise x-coordinates according to the active list

**14. **Scan-Line filling, cont’d When changing from one scan-line to the next, the active edge list is updated:
a record with ymax < ”the next scan-line” is removed
in the remaining records, x0 is incremented and rounded to the nearest integer
an edge with ymin = ”the next scan-line” is included in the list

**15. **Scan-Line Filling Example

**16. **2) Interactive Filling Given the boundaries of a closed surface. By choosing an arbitrary interior point, the complete interior of the surface will be filled with the color of the user’s choice.

**17. **Interactive Filling, cont’d Definition: An area or a boundary is said to be 4-connected if from an arbitrary point all other pixels within the area or on the boundary can be reached by only moving in horizontal or vertical steps.
Furthermore, if it is also allowed to take diagonal steps, the surface or the boundary is said to be 8-connected.

**18. **4/8-connected

**19. **Interactive Filling, cont’d A recursive procedure for filling a 4-connected (8-connected) surface can easily be defined.
Assume that the surface shall have the same color as the boundary (can easily be modified!).
The first interior position (pixel) is choosen by the user.

**20. **Interactive Filling, algorithm void fill(int x, int y, int fillColor) {
int interiorColor;
interiorColor = getPixel(x,y);
if (interiorColor != fillColor) {
setPixel(x, y, fillColor);
fill(x + 1, y, fillColor);
fill(x, y + 1, fillColor);
fill(x - 1, y, fillColor);
fill(x, y - 1, fillColor); } }

**21. **Inside-Outside test When is a point an interior point?
Odd-Even Rule
Draw conceptually a line from a specified point to a distant point outside the coordinate space; count the number of polygon edges that are crossed
if odd => interior
if even => exterior
Note! The vertices!

**22. **Text Representation:
* bitmapped (raster)
+ fast
- more storage
- less good for styles/sizes
* outlined (lines and curves)
+ less storage
+ good for styles/sizes
- slower

**23. **Other output primitives * pattern (to fill an area)
normally, an n x m rectangular color pixel array with a specified reference point
* polymarker (marker symbol)
a character representing a point
* (polyline)
a connected sequence of line segments

**24. **Attributes Influence the way a primitive is displayed
Two main ways of introducing attributes:
added to primitive’s parameter list
e.g. setPixel(x, y, color)
a list of current attributes (to be updated when changed)
e.g setColor(color); setPixel(x, y);

**25. **Attributes for lines Lines (and curves) are normally infinitely thin
type
dashed, dotted, solid, dot-dashed, …
pixel mask, e.g. 11100110011
width
problem with the joins; line caps are used to adjust shape
pen/brush shape
color (intensity)

**26. **Lines with width Line caps
Joins

**27. **Attributes for area fill fill style
hollow, solid, pattern, hatch fill, …
color
pattern
tiling

**28. **Tiling Tiling = filling surfaces (polygons) with a rectangular pattern

**29. **Attributes for characters/strings style
font (typeface)
color
size (width/height)
orientation
path
spacing
alignment

**30. **Text attributes

**31. **Text attributes, cont’d

**32. **Text attributes, cont’d

**33. **Text attributes, cont’d

**34. **Color as attribute Each color has a numerical value, or intensity, based on some color model.
A color model typically consists of three primary colors, in the case of displays Red, Green and Blue (RGB)
For each primary color an intensity can be given, either 0-255 (integer) or 0-1 (float) yielding the final color
256 different levels of each primary color means 3x8=24 bits of information to store

**35. **Color representations Two different ways of storing a color value:
a direct color value storage/pixel
indirectly via a color look-up table index/pixel (typically 256 or 512 different colors in the table)

**36. **Color Look-up Table

**37. **Antialiasing Aliasing ˜ the fact that exact points are approximated by fixed pixel positions
Antialiasing = a technique that compensates for this (more than one intensity level/pixel is required)

**38. **Antialiasing, a method A polygon will be studied (as an example).
Area sampling (prefiltering): a pixel that is only partly included in the exact polygon, will be given an intensity that is proportional to the extent of the pixel area that is covered by the true polygon

**39. **Area sampling P = polygon intensity
B = background intensity
f = the extent of the pixel area covered by the true polygon
pixel intensity =
P*f + B*(1 - f)
Note! Time consuming to calculate f