Escolar Documentos
Profissional Documentos
Cultura Documentos
n
n
P
rx
x - xc y - yc
=1
rx ry
ry
Maintaining Geometric
Properties
n
Inside--Outside Tests
Inside
Odd--even Rule (OddOdd
(Odd-parity Rule)
n
Odd--Even Rule
Odd
n
Odd--Even Rule
Odd
P
Odd--Even Rule
Odd
n
Inside--Outside Tests
Inside
Nonzero Winding Number Rule
n
A winding number
n
n
n
Polygon Tables
n
An object
n
Geometric data
vertex table
n edge table
n surface-fact table
Other parameters
n Color, transparency, lightreflection properties
n
Area Filling
How to generate a solid color/patterned
polygon area
n
n
Which pixels?
What value?
xk+1 = xk + x / y
n
3+2/5
3+4/5
4+1/5
pixel
(3,1)
(3,2)
(4,3)
(4,4)
Span Rules
n
shared vertices
n
n
leftmost : interior
rightmost: exterior
count parity at ymin vertices only
shorten edges
horizontal edges
n
Scan line y
n
n
Scan line y
n
n
Scan line y
n
Scan line y
n
Implementation
n
Coherence properties
n
Scan line 9
Scan line 10
Span Rules
n
shared vertices
n
n
leftmost : interior
rightmost: exterior
count parity at ymin vertices only
shorten edges
horizontal edges
n
Pixel Adjacency
4-connected
8-connected
Boundary-Fill Algorithm
n
Boundary--Fill Algorithm
Boundary
procedure boundaryFill4(
x,y : integer
// starting point in region
borderColor: color // color that defines boundary
fillColor : color); // filling color
var
c : color
begin
c := readPixel(x,y);
if ( c borderColor and c fillColor ) then
begin
writePixel(x,y,newValue);
boundaryFill4(x, y-1, borderColor , fillColor );
boundaryFill4(x, y+1, borderColor , fillColor );
boundaryFill4(x-1, y, borderColor , fillColor );
boundaryFill4(x+1, y, borderColor , fillColor );
end
end;
Boundary--Fill Algorithm
Boundary
There is the following problem with boundary_fill4:
Boundary--Fill Algo
Boundary
Algo..
Efficiency in space!
n
in down to up order
in left to right order
Flood--Fill Algorithm
Flood
n
Flood-Fill Algorithm
n
Flood--Fill Algorithm
Flood
procedure flood_fill4(
x,y: integer //starting point in region
oldValue: color
// value that defines interior
newvalue: color); replacement value
begin
if readPixel(x,y) = oldValue then
begin
writePixel(x,y,newValue);
flood_fill4(x,y-1,oldValue,newValue);
flood_fill4(x,y+1,oldValue,newValue);
flood_fill4(x-1,y,oldValue,newValue);
flood_fill4(x+1,y,oldValue,newValue);
end
end;
Patterned Lines
n
Cosmetic
Geometric
Character, Symbols
n
Character, Symbols
n
Outline font
n
n
n
Less storage
Character, Symbols
Comparison of Methods
Outline font
easy to rotate
easy to scale
variable length storage
scan convert lines
fill if polygons
may be anti-aliased or
smoothed via curve fitting
Bitmap font
rotate by multiples of 90
scale by powers of 2
fixed length storage
scan convert points
draw as filled or outline
may be pre-anti-aliased
Line Attributes
Butt cap
Round cap
Projecting square cap
Miter join
Round Join
Bevel join
Aliasing in CG
Which is
better?
Aliasing in CG
n