You are on page 1of 25

CS2401-COMPUTER GRAPHICS

INTRODUCTION

12/19/2014

COMPUTER GRAPHICS VS ANIMATION:

Computer graphics is just the use


of computers to create an image

Animation is the process of turning


collection of images is to video

12/19/2014

OUTPUT PRIMITIVES:

To describe structure of basic object is referred to as output


primitives.

Structure such as straight line segments and polygon color


areas.

12/19/2014

LINE DRAWING
It is accomplished by calculating intermediate positions along the
line path between two specified end points positions.
An output device is then directed to fill in these positions between
the end points

12/19/2014

ATTRIBUTE OF OUTPUT PRIMITIVES

DEFINITION
Any parameter that affects the way a primitive is to be displayed is
referred to as an attribute parameter.

LINE ATTRIBUTE

CURVE ATTRIBUTE

COLOR AND GRAY SCALE LEVEL

AREA FILLED ATTRIBUTE

TEXT AND CHARACTERS

12/19/2014

LINE ATTRIBUTES
Basic attributes of a straight line segment are its type, its width, and its
color.

Line Type

Line Width

Pen and Brush Options

Line Color

12/19/2014

LINE TYPE
To set line type a user invokes the function
setLinetype (lt)
Integer value- 1
Solid line
Integer value- 2
Dashed line
Integer value- 3
Dotted line
12/19/2014

LINE WIDTH
To set the line width attributes.
setLinewidthScaleFactor(lw)
Line width parameter lw is assigned a positive number
A value of 1 specifies a standard width line.
Values greater than 1 produce lines thicker than the standard.

12/19/2014

LINE CAP
Adjust the shape of the line ends to give them a better appearance by adding
line caps.
There are three types of line cap. They are
Butt cap - displayed with square ends that are perpendicular to the line path.

Round cap - adding a filled semicircle to each butt cap


Projecting square cap - extend the line and add butt caps

12/19/2014

12/19/2014

10

LINE JOINS
Three possible methods for smoothly joining two line segments

Mitter Join - extending the outer boundaries of each of the two lines until
they meet

Round Join - capping the connection between the two segments with a
circular boundary whose diameter is equal to the width

Bevel Join - displaying the line segment with but caps and filling in

tri angular gap where the segments meet

12/19/2014

11

12/19/2014

12

PEN AND BRUSH


. The selected pen or brush determine the way a line will be drawn.
. Pens and brushes have size, shape, color and pattern attribute.

12/19/2014

13

CURVE ATTRIBUTE
Similar to line : type + width
Curves displayed with varying colors, widths, dot dash patterns and available
pen or brush options

12/19/2014

14

COLOR AND GRAY SCALE LEVEL

Colors are represented by colors codes which are positive


integers.

Color information is stored in frame buffer or in separate table


and use pixel values as index to the color table.

Two ways to store color information :


1. Direct
2. Indirect

12/19/2014

COLOR
Direct

12/19/2014

16

COLOR
Indirect

12/19/2014

17

COLOR Lookup Table

12/19/2014

18

COLOR Lookup Table

12/19/2014

19

GRAY SCALE LEVEL

Apply for monitor that have no color


Shades of grey (white->light grey->dark grey->black)
Color code mapped onto grayscale codes
2 bits can give 4 level of grayscale
8 bits per pixel will allow 256 combination
Dividing the actual code with 256 will give range of 0 and 1

Ex:
Color code in color display is 118
To map to nearest grayscale then
118/256 = 0.45
light gray
12/19/2014

20

AREA FILLED ATTRIBUTE


Option for filling a defined region is whether solid , pattern and colors.

Fill Styles
Three basic fill styles are:
Hollow with color border.
Interior color is same with background
Pattern

12/19/2014

21

. filled with a solid color .. color up to and including the border

pattern .. control by other table

12/19/2014

22

TEXT AND CHARACTERS


CHARACTER ATTRIBUTES
The appearance of displayed character is controlled by attributes such as
font, size, color and orientation.
A particular font and associated style is selected using the function
setTextFont(tf)
Text size can be adjusted without changing the width to height ratio of
characters with
SetCharacterHeight (ch)

12/19/2014

23

Spacing between characters is controlled separately with


setCharacterSpacing(cs)

To arrange character strings vertically or horizontally


setTextPath (tp)
where the text path parameter tp can be assigned the value: right, left, up,
or down

12/19/2014

24

12/19/2014

25

You might also like