topic 5 attributes of graphics primitives cgmb214: introduction to computer graphics

36
TOPIC 5 ATTRIBUTES OF GRAPHICS PRIMITIVES CGMB214: Introduction to Computer Graphics

Upload: richard-waters

Post on 27-Dec-2015

228 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: TOPIC 5 ATTRIBUTES OF GRAPHICS PRIMITIVES CGMB214: Introduction to Computer Graphics

TOPIC 5ATTRIBUTES OF GRAPHICS PRIMITIVES

CGMB214: Introduction to Computer Graphics

Page 2: TOPIC 5 ATTRIBUTES OF GRAPHICS PRIMITIVES CGMB214: Introduction to Computer Graphics

Objectives

To understand the characteristic of a primitive

Page 3: TOPIC 5 ATTRIBUTES OF GRAPHICS PRIMITIVES CGMB214: Introduction to Computer Graphics

Color and Gray Scale

Page 4: TOPIC 5 ATTRIBUTES OF GRAPHICS PRIMITIVES CGMB214: Introduction to Computer Graphics

Color and Gray Scale

Color – A basic attribute for all primitivesVarious color option depend on capabilities

and design objectives of a particular system

Page 5: TOPIC 5 ATTRIBUTES OF GRAPHICS PRIMITIVES CGMB214: Introduction to Computer Graphics

RGB Color Components

In color raster system (monitor) Number of color choices available depends on the

amount of storage provided per pixel in the frame buffer

Two method of storing color information in the frame buffer Directly – storing RGB color code directly in the

frame buffer Indirectly – put the color codes into a separate

table and use the pixel locations to store index values referencing the color-table entries

Page 6: TOPIC 5 ATTRIBUTES OF GRAPHICS PRIMITIVES CGMB214: Introduction to Computer Graphics

RGB Color Components

Color Code

Stored Color Values in Frame Buffer Displayed Color

RED GREEN BLUE

0 0 0 0 Black

1 0 0 1 Blue

2 0 1 0 Green

3 0 1 1 Cyan

4 1 0 0 Red

5 1 0 1 Magenta

6 1 1 0 Yellow

7 1 1 1 White

Page 7: TOPIC 5 ATTRIBUTES OF GRAPHICS PRIMITIVES CGMB214: Introduction to Computer Graphics

RGB Color Components

For 24 bit color Store 8 bits each of red,

green and blue perpixel E.g (255,0,0) is pure red

and (255,255,255) is white

Yields 224 = 16 mill colorsFor 15 bit colors

5 bit red+5 bit green+5 bit blue

The video hardware uses the value to drive the R,G and B guns

255 0 0

Page 8: TOPIC 5 ATTRIBUTES OF GRAPHICS PRIMITIVES CGMB214: Introduction to Computer Graphics

RGB Color Components

Disadvantage As more color options are provided, the storage

required for the frame buffer also increases 1024 x 1024 full color (24-bit per pixel) RGB system

needs 3MB of storage for the frame buffer

Solution Storing the color values in a color lookup table (color

map)

Page 9: TOPIC 5 ATTRIBUTES OF GRAPHICS PRIMITIVES CGMB214: Introduction to Computer Graphics

Color Tables

Page 10: TOPIC 5 ATTRIBUTES OF GRAPHICS PRIMITIVES CGMB214: Introduction to Computer Graphics

Color Tables

Values stored in the frame buffer are now used as indices into the color table

Advantages Reduce the frame-buffer storage requirement to

1MB Table entries can be change at any time, allowing a

user to be able to experiment easily with different color combinations without changing the attribute setting for the graphics data structure

When a color value in the color table is changed, all pixels with that color index will change to the new color Without color table, we can only change the color of a pixel

by storing the new color at that frame buffer location

Page 11: TOPIC 5 ATTRIBUTES OF GRAPHICS PRIMITIVES CGMB214: Introduction to Computer Graphics

Point

Page 12: TOPIC 5 ATTRIBUTES OF GRAPHICS PRIMITIVES CGMB214: Introduction to Computer Graphics

Point Attributes

Two attributes of point Color

Set with RGB values or an index into a color table

Size An integer multiple of the pixel size Large point is displayed as a square

block of pixels

Page 13: TOPIC 5 ATTRIBUTES OF GRAPHICS PRIMITIVES CGMB214: Introduction to Computer Graphics

Line

Page 14: TOPIC 5 ATTRIBUTES OF GRAPHICS PRIMITIVES CGMB214: Introduction to Computer Graphics

Line Attributes

Basic attributes Color

Set with the same function for all graphics primitives (using RGB values)

Width Define with separate line functions

Style Define with separate line functions

Special effects for lines Pen Brush Strokes

Page 15: TOPIC 5 ATTRIBUTES OF GRAPHICS PRIMITIVES CGMB214: Introduction to Computer Graphics

Line Width

A standard width line is generated with single pixels at each sample position

Thicker lines are displayed as positive integer multiplies of the standard line Methods

If line slope magnitude ≤ 1.0 use vertical span Plotting a vertical span of pixels in each column (x position)

along the line. If line slope magnitude > 1.0 use horizontal span

Plotting a pixels to the right and left of the line path.

Page 16: TOPIC 5 ATTRIBUTES OF GRAPHICS PRIMITIVES CGMB214: Introduction to Computer Graphics

Line Width

Advantage vertical/horizontal span pixel Quick to generate the thick line

Disadvantage The displayed width of a line is dependent to its

slope i.e. 45 degree line will displayed thinner

compare to vertical and horizontal line The line ends are horizontal or vertical regardless

of the slope of the lineSolution

Adjust the shape of the line ends to give them a better appearance

Page 17: TOPIC 5 ATTRIBUTES OF GRAPHICS PRIMITIVES CGMB214: Introduction to Computer Graphics

Shape of the Line Ends

Square ends that are perpendicular to the line path

Line ends are added with a filled semi circle. Centered at the middle of the thick line. Diameter = the line thickness

Extend the line and add butt caps that are positioned ½ of the line width

Page 18: TOPIC 5 ATTRIBUTES OF GRAPHICS PRIMITIVES CGMB214: Introduction to Computer Graphics

Line Width

Other approach producing a thick line Displaying the line as a filled rectangle Generating the line with a selected pen or brush

Page 19: TOPIC 5 ATTRIBUTES OF GRAPHICS PRIMITIVES CGMB214: Introduction to Computer Graphics

Smooth Connection Line Segment

Method discussed will not produce a smoothly connected series of line segments

It leaves pixels gaps at boundary between line segments with different slope where there is a shift from horizontal pixel spans to vertical pixel spans

Additional processing at the segment endpoints is required to solve the problem

Page 20: TOPIC 5 ATTRIBUTES OF GRAPHICS PRIMITIVES CGMB214: Introduction to Computer Graphics

Smooth Connection Line Segment

3 possible methods for smoothly joining 2 line segments

Extending the outer boundaries of each of the two line segments until they meet

Capping the connecting between two segments with a circular boundary whose diameter = line width

Displaying the line segments with butt caps and filling in the triangular gap where the segments meet

Page 21: TOPIC 5 ATTRIBUTES OF GRAPHICS PRIMITIVES CGMB214: Introduction to Computer Graphics

Line Style

Type Solid Dotted – very short dash with spacing equal to or greater

than dash itself Dashed – displayed by generating an interdash spacing

Pixel count for the span and interspan length is specified by the mask E.g. 111100011110001111

Note: fixed pixel with dashes can produce unequal length dashes. It depends on line orientation. So need to adjust the number of plotted pixel for different slopes

Page 22: TOPIC 5 ATTRIBUTES OF GRAPHICS PRIMITIVES CGMB214: Introduction to Computer Graphics

Pen and Brush

The selected “pen” or “brush” determine the way a line will be drawn

Pens and brushes attributes are size, shape, color and pattern

Pixel mask is applied in both of them

Page 23: TOPIC 5 ATTRIBUTES OF GRAPHICS PRIMITIVES CGMB214: Introduction to Computer Graphics

Curve Attributes

Similar to line: type + width

Thicker curve can be produced by Plotting additional

pixel Filling the space

between two concentric circles

Using thicker pen or brush

Page 24: TOPIC 5 ATTRIBUTES OF GRAPHICS PRIMITIVES CGMB214: Introduction to Computer Graphics

Character

Page 25: TOPIC 5 ATTRIBUTES OF GRAPHICS PRIMITIVES CGMB214: Introduction to Computer Graphics

Character Attributes

We control the appearance of displayed character with attributes such as Font size Color Orientation

Page 26: TOPIC 5 ATTRIBUTES OF GRAPHICS PRIMITIVES CGMB214: Introduction to Computer Graphics

Character Attributes

Text-display option Typeface – choice of font

Set of character with a particular design i.e. courier, helvetica, times roman etc.

Assorted underlining styles Solid, dotted, double

Boldface Italic Emboss Shadow style

Page 27: TOPIC 5 ATTRIBUTES OF GRAPHICS PRIMITIVES CGMB214: Introduction to Computer Graphics

Character Attributes

Color settings Can be stored in the system attribute list

and used by the procedures that generate character definition in the frame buffer

Current color is used to set pixel values in the frame buffer corresponding to the character shapes and position

Page 28: TOPIC 5 ATTRIBUTES OF GRAPHICS PRIMITIVES CGMB214: Introduction to Computer Graphics

Character Attributes

Text size By scaling the overall dimensions of

character Height Width

Or scaling the height only Or scaling the width only

Page 29: TOPIC 5 ATTRIBUTES OF GRAPHICS PRIMITIVES CGMB214: Introduction to Computer Graphics

Character Attributes

Orientation Set according to the direction of a character up vector

Orientation of character from baseline to capline is in the direction of up vector

Set using text-path orientation Arrange the character strings vertically or horizontally or

forward or backward Adjust the position of the individual characters in the

frame buffer according to the option selected Combination of up-vector and text-path to produce

slanted text

Page 30: TOPIC 5 ATTRIBUTES OF GRAPHICS PRIMITIVES CGMB214: Introduction to Computer Graphics

Character Attributes

Other attributes Character spacing

Spacing between character Alignment

How text is to be displayed with respect to a reference position Align according to the base line Align according to the character center

Text-precision attribute (in some graphics packages) Specify the amount of detail and the particular

processing options that are to be used with the text string

Special character

Page 31: TOPIC 5 ATTRIBUTES OF GRAPHICS PRIMITIVES CGMB214: Introduction to Computer Graphics

Antialiasing

Page 32: TOPIC 5 ATTRIBUTES OF GRAPHICS PRIMITIVES CGMB214: Introduction to Computer Graphics

Antialiasing

A methods that compensate for the undersampling process (aliasing)

Aliasing Is a distortion of information due to low-frequency

sampling (under-sampling) The sampling process digitizes coordinate points on an

object to discrete integer pixel position Resulting

A jagged, or stair-step appearance

Page 33: TOPIC 5 ATTRIBUTES OF GRAPHICS PRIMITIVES CGMB214: Introduction to Computer Graphics

Antialiasing

Page 34: TOPIC 5 ATTRIBUTES OF GRAPHICS PRIMITIVES CGMB214: Introduction to Computer Graphics

Antialiasing

One way to increase sampling rate with raster system Simply to display objects at higher resolution Even with highest resolution, the jaggies still apparent

to some extent So it is not a complete solution

Other antialising method may be applied

Page 35: TOPIC 5 ATTRIBUTES OF GRAPHICS PRIMITIVES CGMB214: Introduction to Computer Graphics

Antialiasing Methods

Supersampling Straight Line Segments Divide each pixel into a number of subpixels and count the number of

subpixels that overlap the line path. The intensity level is for each pixel is then set to a value that is

proportional to this subpixel count. Involve computing intensities at subpixel grid position, then combine

the results to obtain the pixel intensities Area sampling (prefiltering)

Determine pixel intensity by calculating the areas of overlap of each pixel with the object to be displayed

Pixel phasing Shifting the display location of pixel areas Applied by “micropositioning” the electron beam in relation to object

geometry Filtering techniques (postfiltering)

More accurate method for antialiasing lines Methods similar to applying a weighted pixel mask, but now we

imagine a continuous weighting surface covering the pixel Antialiasing Area Boundary

Applying an antialiasing concepts for boundaries area

Page 36: TOPIC 5 ATTRIBUTES OF GRAPHICS PRIMITIVES CGMB214: Introduction to Computer Graphics

References

http://www.gamegen.com.br/