Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 'unrolled floodfill
- randomize timer
- const false=0, True = not False, ScreenWidth = 640, ScreenHeight = 480
- declare sub Paint2(byval pX as integer, byval pY as integer, byval Col as uinteger, byval scol as uinteger )
- screenres screenwidth, screenheight, 32
- screenlock
- for i as integer = 1 to 1000
- dim as integer rx = int(rnd*ScreenWidth)
- dim as integer ry = int(rnd*ScreenHeight)
- dim as integer rad = rnd*100
- dim as uinteger rcol = rgb(rnd*255, rnd*255, rnd*255)
- dim as uinteger rbor = rgb(rnd*255, rnd*255, rnd*255)
- circle(rx,ry),rad,rbor
- paint2( rx, ry, rcol, rbor )
- next
- screenunlock
- sleep
- sub Paint2( byval pX as integer, byval pY as integer, byval Col as uinteger, byval scol as uinteger)
- static as integer sw, sh
- static as uinteger tcol
- static as uinteger ptr scr
- screeninfo sw,sh
- if py<0 or px<0 or px>sw-1 or py>sh-1 then exit sub
- dim as integer i = 0, bwid = (sw * sh) * 2, x ,y
- dim as ushort FloodId(bwid)
- FloodId(i) = pX
- FloodId(i+1) = pY
- i += 2
- scr = screenptr
- do while i
- i -= 2
- x = FloodId(i)
- y = FloodId(i+1)
- scr[y*sw+x] = col
- if y>0 then
- tcol = scr[ ((y-1)*sw) + x]
- if tcol <> scol and tcol <> col then
- FloodId(i) = X
- FloodId(i+1) = Y - 1
- i += 2
- end if
- end if
- if x>0 then
- tcol = scr[(y*sw)+x-1]
- if tcol <> scol and tcol <> col then
- FloodId(i) = X - 1
- FloodId(i+1) = Y
- i += 2
- end if
- end if
- if y<sh-1 then
- tcol = scr[(y+1)*sw+x]
- if tcol <> scol and tcol <> col then
- FloodId(i) = X
- FloodId(i+1) = Y + 1
- i += 2
- end if
- end if
- if x<sw-1 then
- tcol = scr[(y*sw)+(x+1)]
- if tcol <> scol and tcol <> col then
- FloodId(i) = X + 1
- FloodId(i+1) = Y
- i += 2
- end if
- end if
- loop
- end sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement