Subdomain Posts
FreeBasic | 12 hours ago
FreeBasic | 1 day ago
FreeBasic | 2 days ago
FreeBasic | 2 days ago
Pascal | 2 days ago
FreeBasic | 4 days ago
FreeBasic | 4 days ago
XML | 7 days ago
FreeBasic | 9 days ago
PHP | 9 days ago
Recent Posts
JavaScript | 9 sec ago
XML | 2 min ago
CSS | 2 min ago
None | 2 min ago
None | 2 min ago
None | 2 min ago
REBOL | 3 min ago
None | 3 min ago
PHP | 4 min ago
None | 4 min ago
Sitereport
Find cool info about any domain on the internet?
visit sitereport
Free Subdomains
Want a pastebin.com sub-domain for your community?
learn more...
What is pastebin?
Pastebin is a website that hosts all your text & code on dedicated servers for easy sharing.
learn more...
Learn a little bit about the new Pastebin.com on our help page. hide message
By Anonymous on the 5th of Feb 2010 01:59:27 PM Download | Raw | Embed | Report
  1. #include once "fbgfx.bi"
  2.  
  3. #undef fb_GfxPaint
  4. sub fb_GfxPaint alias "fb_GfxPaint" _
  5.         ( _
  6.                 byval target       as any ptr, _
  7.                 byval fx           as single, _
  8.                 byval fy           as single, _
  9.                 byval _color       as uinteger, _
  10.                 byval border_color as uinteger, _
  11.                 byref pattern      as string, _
  12.                 byval mode         as integer, _
  13.                 byval flags        as integer _
  14.         )
  15.  
  16.         #define STK_INIT 1024
  17.         #define STK_STEP 1024
  18.  
  19.         dim as integer ptr  stk   = any
  20.         dim as integer      stk_p = 0
  21.         dim as integer      stk_s = STK_INIT
  22.         dim as any ptr      p     = any
  23.         dim as integer      w     = any
  24.         dim as integer      h     = any
  25.         dim as integer      bpp   = any
  26.         dim as integer      pitch = any
  27.         dim as integer      x     = fx
  28.         dim as integer      y     = fy
  29.  
  30.         if target = 0 then
  31.                 p = screenptr
  32.                 screeninfo w, h, , bpp, pitch
  33.         else
  34.                 p = target + sizeof( fb.image )
  35.                 w = cast( fb.image ptr, target )->width
  36.                 h = cast( fb.image ptr, target )->height
  37.                 bpp = cast( fb.image ptr, target )->bpp
  38.                 pitch = cast( fb.image ptr, target )->pitch
  39.         end if
  40.  
  41.         if (x < 0) or (y < 0) or (x >= w) or (y >= h) then exit sub
  42.  
  43.         dim as uinteger fc = cast( uinteger ptr, p + (y * pitch) )[x]
  44.  
  45.         if fc = _color then exit sub
  46.  
  47.         if target = 0 then
  48.                 screenlock
  49.         end if
  50.  
  51.         stk = allocate( stk_s * sizeof( integer ) )
  52.  
  53.         stk[stk_p+0] = x
  54.         stk[stk_p+1] = y
  55.         stk_p += 2
  56.  
  57.         while stk_p
  58.                 dim as integer onA = 0
  59.                 dim as integer onB = 0
  60.  
  61.                 stk_p -= 2
  62.                 x = stk[stk_p+0]
  63.                 y = stk[stk_p+1]
  64.  
  65.                 dim as uinteger ptr row = cast( uinteger ptr, p + (y * pitch) )
  66.  
  67.                 while x
  68.                         if row[x-1] <> fc then exit while
  69.                         x -= 1
  70.                 wend
  71.  
  72.                 while x < w
  73.                         if row[x] <> fc then exit while
  74.                         row[x] = _color
  75.  
  76.                         if y > 0 then ' can look above
  77.                                 dim as uinteger ptr arow = cast( any ptr, row ) - pitch
  78.                                 if arow[x] = fc then
  79.                                         if onA = 0 then
  80.                                                 if stk_p >= stk_s then
  81.                                                         stk_s += STK_STEP
  82.                                                         stk = reallocate( stk, stk_s * sizeof( integer ) )
  83.                                                 end if
  84.                                                 stk[stk_p+0] = x
  85.                                                 stk[stk_p+1] = y - 1
  86.                                                 stk_p += 2
  87.                                         end if
  88.                                         onA = -1
  89.                                 else
  90.                                         onA = 0
  91.                                 end if
  92.                         end if
  93.  
  94.                         if y < (h - 1) then ' can look below
  95.                                 dim as uinteger ptr brow = cast( any ptr, row ) + pitch
  96.                                 if brow[x] = fc then
  97.                                         if onB = 0 then
  98.                                                 if stk_p >= stk_s then
  99.                                                         stk_s += STK_STEP
  100.                                                         stk = reallocate( stk, stk_s * sizeof( integer ) )
  101.                                                 end if
  102.                                                 stk[stk_p+0] = x
  103.                                                 stk[stk_p+1] = y + 1
  104.                                                 stk_p += 2
  105.                                         end if
  106.                                         onB = -1
  107.                                 else
  108.                                         onB = 0
  109.                                 end if
  110.                         end if
  111.  
  112.                         x += 1
  113.                 wend
  114.         wend
  115.  
  116.         if target = 0 then
  117.                 screenunlock
  118.         end if
  119.  
  120.         deallocate( stk )
  121.  
  122. end sub
  123.  
  124.  
  125. #define scr_wid 800
  126. #define scr_hei 600
  127.  
  128. sub yetiflood _
  129.         ( _
  130.                 byval x as integer, _
  131.                 byval y as integer, _
  132.                 byval c as uinteger _
  133.         )
  134.  
  135.         if (cast( uinteger, x ) >= cast( uinteger, scr_wid )) _
  136.         or (cast( uinteger, y ) >= cast( uinteger, scr_hei )) then exit sub
  137.  
  138.         #define stack_size 8192
  139.         static stack(0 to stack_size - 1) as integer
  140.         dim stack_pos as integer = stack_size
  141.  
  142.         dim as uinteger ptr screen_p = screenptr( )
  143.         dim as uinteger     fc       = screen_p[(y * scr_wid) + x]
  144.        
  145.         'if fc = c then exit sub
  146.  
  147.         screenlock
  148.  
  149.         stack_pos -= 2
  150.         stack(stack_pos+0) = x
  151.         stack(stack_pos+1) = y
  152.  
  153.         while stack_pos < stack_size
  154.                 x = stack(stack_pos+0)
  155.                 y = stack(stack_pos+1)
  156.                 stack_pos += 2
  157.  
  158.                 dim as uinteger ptr p        = @screen_p[y * scr_wid]
  159.                 dim as integer      on_lineA = 0
  160.                 dim as integer      on_lineB = 0
  161.                 dim as integer      ya       = y - 1
  162.                 dim as integer      yb       = y + 1
  163.                 dim as integer      ya_good  = (ya < scr_hei) and (ya >= 0)
  164.                 dim as integer      yb_good  = (yb < scr_hei) and (yb >= 0)
  165.                 dim as uinteger ptr ya_p     = @p[-scr_wid]
  166.                 dim as uinteger ptr yb_p     = @p[scr_wid]
  167.  
  168.                 while x > 0
  169.                         if p[x - 1] <> fc then exit while
  170.                         x -= 1
  171.                 wend
  172.  
  173.                 while x < scr_wid
  174.                         if p[x] <> fc then exit while
  175.                         p[x] = c
  176.  
  177.                         if ya_good then
  178.                                 if ya_p[x] = fc then
  179.                                         if on_lineA = 0 then
  180.                                                 stack_pos -= 2
  181.                                                 stack(stack_pos+0) = x
  182.                                                 stack(stack_pos+1) = ya
  183.                                                 on_lineA = 1
  184.                                         end if
  185.                                 else
  186.                                         on_lineA = 0
  187.                                 end if
  188.                         end if
  189.  
  190.                         if yb_good then
  191.                                 if yb_p[x] = fc then
  192.                                         if on_lineB = 0 then
  193.                                                 stack_pos -= 2
  194.                                                 stack(stack_pos+0) = x
  195.                                                 stack(stack_pos+1) = yb
  196.                                                 on_lineB = 1
  197.                                         end if
  198.                                 else
  199.                                         on_lineB = 0
  200.                                 end if
  201.                         end if
  202.  
  203.                         x += 1
  204.                 wend
  205.  
  206.         wend
  207.  
  208.         screenunlock
  209.  
  210. end sub
  211.  
  212.  
  213. screenres scr_wid,scr_hei,32
  214.  
  215.  
  216. for i as integer = 1 to 50
  217.        
  218.     dim as integer rx = int(rnd*Scr_Wid)
  219.     dim as integer ry = int(rnd*Scr_Hei)
  220.     dim as integer rad = rnd*100
  221.     dim as uinteger rcol = 255'rnd*1677215
  222.  
  223.     circle(rx,ry),rad,rcol
  224.    yetiflood( rx, ry, rcol )
  225.         'paint (rx, ry), rcol
  226. next
  227.  
  228. sleep
Submit a correction or amendment below. Make A New Post
To highlight particular lines, prefix each line with @h@
Syntax highlighting:
Post expiration:
Post exposure:
Name / Title:
Email: