Uploaded by sexeget318

sdvsdss

advertisement
NAME REPALA SUDnAMSW
ROLL
CS0351
Assianmtnf 3
1901506 2
RANCW: COM PUT ER SCIENCE
)
Sanlint Polygon Filling Alaori thm
Ihis
algpvithm
malnly based
is
eoch linc
pa ivs fov
fiL the
of
to
Ifncs)
thostx-intrept paivs
the
tiifng of
fo
Scveen (stan
bttwttn
bowndarits
leading
the
qent reting-infevepT
on
tomplet poly90n
SLonlinCs
poooccendDDood
As
n
shown
wheve
flling
the
Makt
a
of
ponts
table
dingvam, eoch
tnside
stanlint is tilled
polygon
the
thus
polyo9on
eithev
dfvection
of Ymax, Ymin ,/m
valuts
Containing
edges
clockwise
2)
ave
entfve
the
ol1
above
the
n
cownter clockwise
and ako
X
or
of Vmin
nd ont if the ve ave any tonselntivc lfnes , where
the
is monofonically neveasing
valne
delveasing,
it so
C0-ovdinate
of
3Ffnd
and
and
bastd
all the
sort
on
deuveose
the
or
the endpoin ts
lower cdge
by 1
ntevtection X, nith all stan line
AlLovdíngly
theiv
valne
for
eveyy sanlíne
except fov horizontal
edges)
All
qenevate patvs for
4
5
Sov ted
X-intevcepte
Fil
intevcept pafvs
tht
aLtovdfng
patttvn
6Achitve
Ex
Polyaon
the
sconlfnts
based
pon the
w?th veanired colouy
to th veaivemtnt
flnal
vtanlved
frllcd
or
polypn
A l , B ( 81), c (B16),
with vertiuts
D53), E(1,7).
am
For onveniente,
AE DBA
For
vepvesenting
E(t)
them
gping to oYder thtm
the
as
aS
poly9on
CL8,6)
D(S13)
11)
8(6)
Kongn dfagram
min max X
Edge table
(,)
ElT)
IEl1+)
bl3)
2
c (86
4
D5,3)
C(8,6)
B8
(B1)
A(1
-
5
3
3
6
6
NA
2
Pre Vions
Action
TMpe
neXt
Aurvent
xtvema
ACI)
B (8)
E7
Maxim
MpeMcYn
DS3)
E (17)
A (11)
Nonc
MinimaNone
cl8,4)
Ve >Mcn
B(B)
MpM7Y
E C1,7) D(5,9
p I5,3)
None
YpMcn
MAximANone
c(8,6)
None
MinimA
c
AS
B
l8,6)
Wthave only
în
vevtice
Vp>YYn
A (1)
(B,1)
need
CxtvewMas, we dowot
to
modity
any
Case.
this
Findfng x-inteviepts
Mmin
Edge
O
MmaX
(17)
Stan lfnt
Xlnteys eution
2
Mmin
7)
(
3
max
X
(s13)
X =s)
,M =h,
X
=
X=3), (1=6,
S-), M- 5,
X= 2
IM=P, x=
Edge
(53)
nmin MAXX
m
(8,6)
S
3
SCanline
X
3
5
Edge3
(8,4) ()
m Ymna X
6
Scanlin
2
St1
X
8t0 8
b
7+1 8
m
M
Fdge
(1) C,1)
iNA
X
Scanltne
We
max X
min
do not
considey
hovitOntal
ftnding X-inte vtept.
lints while
IntevseLtion table
0
Edge
2
X
ovdevedp
3
B
13
12
X
(1 8)
2
C15), CS,8)
S
8
3
2
TB
(1,M),(G,8
x
(1367,8
C2)(88)
88
X
t)
Dfagvam
(cveen)
8|
2) Bowndary- Fil Algorithm
) w start from an
bonnd ay
by
pixel in tht interiov of a vegton defined
and
ftli
ntil the
pixel by plxel
bonnda?y ' enLonntered.
6-0n ne tted
ovdovinq of pixels tvo nntered
8-0nne cted pixels
)
2
we
Se
a
stack to stove all the
tonne cte d
pxel auording to the order, whtch
filled
and
not
on
tht
doing
dots fov fhe
not
v
vent
alvendy
bonud ary-
AlqorithmM
vold
ave
while
bonndary RllB ({nt x,
inty,
int tillcolov, int bonndmycolot)
int cu Ve nt
etpixel (XM);
loy
if tnvve vt 1= bonnd aryD
Cuvvent
=
3 aMYYe nt | =ffllLolor)
setcolovlfi1l)
Setpixel (x1) ,
bond oryfill8(xtl, fill, bonndaryoloY)
bond avytill8|x, v-, fill color, bonndavyto loY)
bonndary fill8(x-i 1, fillcolor, bonndarytolor|
_
oonnd ar yfillb (x+1, y, fi ll Lolor, boundaryolor]
bondarytill &
x-I,M +I, fillo lov, boun dorytoo
boundarytius( x*1, 1+1,
fill, boundar1)
bowndovyfrl B ( x-1, M-
Fill, boundau)
bo nd aY y ilis ( X+I, V-1, FIll, bonndary)
3
S
fov
the
iam
Sowne
example
Al1,),
asswming
the
Ifne dvawinq
Covey
B(811),
c(8 16),
bonndayy
algoritfhm
D5,3),E(1*)
is d rawn s i n
(breshen haw's)
the bondary
h-d
POP
Start posltion
pOp
all
heiqhbowrs
Cxploved
POP
13
10
POp
12,0
PoP 13
Fop
XXX
D
Fnal filed
polyaon
14,9,5,
to
In the spantlood fill algorithm, we store the be atnníng
two bovnd ary
on S a n l i ' n e be twetn
lach
piXel of
span
stack, whlch
Plxels in
we
Startin4
tvom
Contiqnos
Thtn
we
spans
fixek
os
positions
ng of
on
sLan
tht
positions
lincs,
fo
where
contignos hori
loonnded
suon line
this startin4
+ing
stack
Adjactut
displayed
AVE
StYi
and
the
th
till
Intevior point, ne fivst
of
an
loc ate
on
an
eH lele ncy
enth span
beglnnfng potitiov
netd thet
oniy
the
mivens ES
by pixels
spans
zontal
displa yed
by border colo
We
vetrieve
Stack
the
nd
hext Start
vepeat
the
positiovn
from
top f
the
protess
Example
7
Owr veauived
filled poly 9On
8
Download