Lesson5
Lesson5
OF
AGRICULTURE & TECHNOLOGY
JKUAT SODeL
Nairobi, Kenya
E-mail: [email protected]
Back Close 0
ICS 2311 Computer Graphics
LESSON 5
2D Scan Raster Conversion
5.1. Introduction
JKUAT SODeL
’primitives’.
The term is mainly used for drawing methods for 2D picture
elements or primitives such as lines, polygons and text.
All three of these are used in Java programs we shall be
considering.
JJ II
In contrast, general 3D drawing methods are termed render-
J I
J DocDoc I
JKUAT: Setting trends in higher Education, Research and Innovation
Back Close 1
ICS 2311 Computer Graphics
ing methods, though some of these may use 2D picture primi-
tives.
as 0=mx+c−y.
Most line and curve drawing methods effectively hunt along
a pixel at a time, steering left or right as needed to find a trail
of pixels to be drawn, by calculating which next pixel will keep
the relevant function closest to zero.
JJ II Most line or curve drawing methods do their hunt for pixels
J I using only integer calculations.
J DocDoc I
JKUAT: Setting trends in higher Education, Research and Innovation
Back Close 2
ICS 2311 Computer Graphics
The time taken to draw a line or curve increases mainly in
proportion to the number of pixels to be drawn.
Circular and elliptical arcs take longer to draw than straight
lines.
JKUAT SODeL
Back Close 3
ICS 2311 Computer Graphics
systems for purely 2D graphics painting or photographic
image manipulation.
The time taken to draw a filled area increases mainly in propor-
tion to the number of pixels to be drawn but also in proportion
JKUAT SODeL
5.1.4. Text:
2D scan conversion of Text uses either of the following methods:
1. raster fonts,
JJ II 2. line drawing, or
J I 3. area drawing.
J DocDoc I
JKUAT: Setting trends in higher Education, Research and Innovation
Back Close 4
ICS 2311 Computer Graphics
Raster fonts are already scan-converted; each character is quickly
painted in place by a raster-op. This way of drawing text does
not cater for sloping text or text which gradually changes size.
Line-drawn fonts are mainly used in Computer Aided Design,
JKUAT SODeL
Back Close 5
ICS 2311 Computer Graphics
5.1.5. Aliasing in 2D Drawing
Simply choosing some pixels to draw often results in the familiar
’jaggies’. This is a form of aliasing. Aliasing in computing gener-
ally is substitution of something (e.g. some pixels) for something
JKUAT SODeL
1. Outline aliasing
2. Motion aliasing
3. Color aliasing
• Outline aliasing:
JJ II Outline aliasing refers to the unintended jagged appearance of
J I lines, curves or area boundaries.
J DocDoc I
JKUAT: Setting trends in higher Education, Research and Innovation
Back Close 6
ICS 2311 Computer Graphics
This can be overcome using ’antialiasing’ methods
• These provide smoothness at the cost of slight blurring,
by altering pixel colours in proportion to how well they
match the ideal area to be drawn.
JKUAT SODeL
• Motion aliasing:
©2014
Back Close 7
ICS 2311 Computer Graphics
in the timing of repainting of successive frames.
• Colour aliasing:
Colour aliasing is due to colour approximation in pseudo-colour
displays.
JKUAT SODeL
Back Close 8
ICS 2311 Computer Graphics
To draw a line on the screen, we first need to determine which
pixels are to be switched ON.
The process of determining which combination of pixels pro-
vide the best approximation to the desired line is called rasteri-
JKUAT SODeL
zation.
When rasterization is combined with rendering of a picture
in a scan-line order, then it is known as scan-conversion.
©2014
Back Close 9
ICS 2311 Computer Graphics
2. Lines should start and end accurately
3. Lines should have constant brightness along their length
4. Lines should be drawn rapidly.
For straight lines, the equation of a straight line is used to de-
JKUAT SODeL
Back Close 10
ICS 2311 Computer Graphics
Revision Questions
Back Close 11
ICS 2311 Computer Graphics
Solutions to Exercises
Exercise 1.
JJ II
J I
J DocDoc I
JKUAT: Setting trends in higher Education, Research and Innovation
Back Close 12