33
Digital Media Lecture 5: Vector Graphics Georgia Gwinnett College School of Science and Technology Dr. Jim Rowan

Digital Media Lecture 5: Vector Graphics Georgia Gwinnett College School of Science and Technology Dr. Jim Rowan

Embed Size (px)

DESCRIPTION

Vector Graphics… An elegant way to construct digital images that –can have a compact representation –are scalable –provdes access to the objects And mandatory for 3-D modeling

Citation preview

Page 1: Digital Media Lecture 5: Vector Graphics Georgia Gwinnett College School of Science and Technology Dr. Jim Rowan

Digital Media

Lecture 5: Vector Graphics

Georgia Gwinnett CollegeSchool of Science and Technology

Dr. Jim Rowan

Page 2: Digital Media Lecture 5: Vector Graphics Georgia Gwinnett College School of Science and Technology Dr. Jim Rowan

So far…

We have compared bitmapped graphics and vector graphics

We have discussed bitmapped images, some file formats and some file compression techniques

Today we are going to talk in a bit more detail about vector graphics

Later we will cover Color Then 3D vector graphics

Page 3: Digital Media Lecture 5: Vector Graphics Georgia Gwinnett College School of Science and Technology Dr. Jim Rowan

Vector Graphics…

An elegant way to construct digital images that – can have a compact representation – are scalable– provdes access to the objects

And mandatory for 3-D modeling

Page 4: Digital Media Lecture 5: Vector Graphics Georgia Gwinnett College School of Science and Technology Dr. Jim Rowan

But first:

Coordinate systems

Page 5: Digital Media Lecture 5: Vector Graphics Georgia Gwinnett College School of Science and Technology Dr. Jim Rowan

Coordinate SystemsBitmapped pixel coordinates (integer)4,0 4,1 4,2 4,9

3,0 3,1 3,2 3,9

0,0 0,1 0,2 0,9

x

y

0

1

2

3

4

0 1 2 3 4 9

Page 6: Digital Media Lecture 5: Vector Graphics Georgia Gwinnett College School of Science and Technology Dr. Jim Rowan

Coordinate SystemsBitmapped pixel coordinates (integer)

A

E

C D

x

y

0

1

2

3

4

0 1 2 3 4 9

B

5 6

A?= ( , ) B?= ( , ) C?= ( , ) D?= ( , ) E?= ( , )

Page 7: Digital Media Lecture 5: Vector Graphics Georgia Gwinnett College School of Science and Technology Dr. Jim Rowan

Coordinate SystemsVector graphics coordinates (real values)

A point is defined by its x and y coordinate

0 1 2 3

1

2

x

y

(1.41, 1.74)(x,y)

They can be fractionalThey can be negative

Page 8: Digital Media Lecture 5: Vector Graphics Georgia Gwinnett College School of Science and Technology Dr. Jim Rowan

Vector graphics coordinates (real values)A displacement (distance between points or movement from one

point to another) can be defined by a pair of points

0 1 2 3

1

2

x

y

(1.41, 1.74)point 1

(3.12, 0.95)

displacement from point 1 to point 2?displacement = = [(x2 - x1), (y2 - y1)] = (3.12 - 1.41, 0.95 - 1.74) = (1.71,-0.79)

point 2

Coordinate Systems

Page 9: Digital Media Lecture 5: Vector Graphics Georgia Gwinnett College School of Science and Technology Dr. Jim Rowan

Vectors have magnitude (length) and direction This vector goes down 0.79 and to the right 1.71 (1.71 , -0.79)

0 1 2 3

1

2

x

y

(1.41, 1.74)point 1

(3.12, 0.95)point 2

Vectors

Page 10: Digital Media Lecture 5: Vector Graphics Georgia Gwinnett College School of Science and Technology Dr. Jim Rowan

Why “vector graphics?”

This is a grandfathered term

It comes from the CRT days when displays could be directly “steered” by their programs

A program passed a vector to the display and the beam would move to the next point drawing a line

Page 11: Digital Media Lecture 5: Vector Graphics Georgia Gwinnett College School of Science and Technology Dr. Jim Rowan

Next:

Absolute vs Windowcoordinate systems

Page 12: Digital Media Lecture 5: Vector Graphics Georgia Gwinnett College School of Science and Technology Dr. Jim Rowan

Absolute vs Window

Applications render images inside of a window– They know where stuff is in the window– But not where the window is– They deal with relative coordinates

The Operating system– Keeps up with the window– It deals with absolute coordinates

Page 13: Digital Media Lecture 5: Vector Graphics Georgia Gwinnett College School of Science and Technology Dr. Jim Rowan

Absolute vs Window

absolute – coordinates: measured back to the upper

left hand corner of the screen relative (to the window)

– coordinates measurement back to the upper left hand corner of the window

to convert relative to absolute, add the relative coordinates to the absolute coordinate of the upper left hand corner of that window

Page 14: Digital Media Lecture 5: Vector Graphics Georgia Gwinnett College School of Science and Technology Dr. Jim Rowan
Page 15: Digital Media Lecture 5: Vector Graphics Georgia Gwinnett College School of Science and Technology Dr. Jim Rowan

The bounding box

It’s a way to locate an object in space what point is used to place an object?

– the center of the object’s mass?– the upper left corner?– the lower right corner?

images can be contained inside a “bounding box” which is the smallest box that contains all the points found in an object

Page 16: Digital Media Lecture 5: Vector Graphics Georgia Gwinnett College School of Science and Technology Dr. Jim Rowan

Bounding boxes; relative and absolute coordinatesx

y

(0,0)

window 1

window 1

desktop screen

bounding box

(210,175)

window

(410,290)

(760,570)

(100,103)

Page 17: Digital Media Lecture 5: Vector Graphics Georgia Gwinnett College School of Science and Technology Dr. Jim Rowan

Finally: Vector Graphics

Store shapes economically in the form of formulas or equations of geometric shapes

A line segment can be completely described by its two endpoints…

Let’s look at the line a little closer

Page 18: Digital Media Lecture 5: Vector Graphics Georgia Gwinnett College School of Science and Technology Dr. Jim Rowan

Here’s the vector we saw earlier defined by it’s two endpoints

0 1 2 3

1

2

x

(1.41, 1.74)

(3.12, 0.95)

Page 19: Digital Media Lecture 5: Vector Graphics Georgia Gwinnett College School of Science and Technology Dr. Jim Rowan

But…

To display a vector graphic you need to convert the vector to a bitmapped graphic…

This presents problems!

Page 20: Digital Media Lecture 5: Vector Graphics Georgia Gwinnett College School of Science and Technology Dr. Jim Rowan

Convert Vector to BitmappedVisually...

“completely cover the vector with pixels”

0 1 2 3

1

2

x

Page 21: Digital Media Lecture 5: Vector Graphics Georgia Gwinnett College School of Science and Technology Dr. Jim Rowan

Convert Vector to BitmappedVisually...

“completely cover the vector with pixels”

0 1 2 3

1

2

x

Page 22: Digital Media Lecture 5: Vector Graphics Georgia Gwinnett College School of Science and Technology Dr. Jim Rowan

Convert Vector to BitmappedResults in an artifact…

a jagged line called an alias that lookslike a series of steps

0 1 2 3

1

2

x

Page 23: Digital Media Lecture 5: Vector Graphics Georgia Gwinnett College School of Science and Technology Dr. Jim Rowan

How to mitigate this alias?Anti-aliasing techniques are used but…How does this work?

0 1 2 3

1

2

x

Page 24: Digital Media Lecture 5: Vector Graphics Georgia Gwinnett College School of Science and Technology Dr. Jim Rowan

Anti-aliasing

0 1 2 3

1

2

x

our pixellated line to be displayed is in black

Page 25: Digital Media Lecture 5: Vector Graphics Georgia Gwinnett College School of Science and Technology Dr. Jim Rowan

Anti-aliasing

0 1 2 3

1

2

x

the original vector graphic stored in the internal model is in red

our pixellated line to be displayed is in black

Page 26: Digital Media Lecture 5: Vector Graphics Georgia Gwinnett College School of Science and Technology Dr. Jim Rowan

Anti-aliasing

0 1 2 3

1

2

x

Page 27: Digital Media Lecture 5: Vector Graphics Georgia Gwinnett College School of Science and Technology Dr. Jim Rowan

Anti-aliasing

0 1 2 3

1

2

x

Page 28: Digital Media Lecture 5: Vector Graphics Georgia Gwinnett College School of Science and Technology Dr. Jim Rowan

Vector Graphics: drawing smooth curves?

• Question: How would you draw a curve using a computer with a mouse?

• You can’t draw smooth lines very easily• A line tool with handles (based on the

Bezier curve) can be manipulated by those handles

Page 29: Digital Media Lecture 5: Vector Graphics Georgia Gwinnett College School of Science and Technology Dr. Jim Rowan

Lines and curves?

Bezier curves can be smoothly joined together

An anchor point is the point where one joins the other

When a curve closes on itself it is considered a closed curve

When it doesn’t it’s an open curve

Page 30: Digital Media Lecture 5: Vector Graphics Georgia Gwinnett College School of Science and Technology Dr. Jim Rowan

Lines and curves?

Closed (and open for that matter) lines can be filled– solid color, pattern or gradient (linear or

radial) Lines can have different ends

– mitre, rounded, square, bevel

Page 31: Digital Media Lecture 5: Vector Graphics Georgia Gwinnett College School of Science and Technology Dr. Jim Rowan

The language of Manipulating objects…

Translation: is a simple up/down side-to-side movement

Scaling: make bigger or smaller Rotation: about a point Reflection: about a line

Page 32: Digital Media Lecture 5: Vector Graphics Georgia Gwinnett College School of Science and Technology Dr. Jim Rowan

3D vector graphics?

MUCH more complex than 2-D 3-D shapes (objects) are defined by

their surfaces Made even more complicated by the

fact that a 3-D object built inside the computer must be displayed as a 2-D graphic on a computer screen...– This results in the need to specify the

viewpoint

Page 33: Digital Media Lecture 5: Vector Graphics Georgia Gwinnett College School of Science and Technology Dr. Jim Rowan