Latest UploadsNom nom nomJayenkaiRainbow TroutPakzKing SalmonPakzSnookerJayenkaiYou've ... o have youJayenkaiMerry XmasJayenkai
 Code Snippets > Misc ( Created 11 January 2007 | Last Edited 11 January 2007)

 Floodfill Function by mike_g | No Votes Written inBlitz Heres a little floodfill function I made in case anyone needs one. Its kind of slow and simple so if anyone has a better floodfill routine I would like to see it Type fill Field x, y End Type ;---------------------------------------; ;************** DEMO PROG **************; ;---------------------------------------; SeedRnd MilliSecs() SetBuffer BackBuffer() For i = 1 To 10 Oval Rand(0, 200), Rand(0, 200), Rand(10, 100), Rand(10, 100), 0 Next While Not KeyHit(1) If MouseHit(1) Then FLOODFILL(MouseX(), MouseY(), \$ff00ff) Flip Wend ;---------------------------------------; ;***************************************; ;---------------------------------------; Function FLOODFILL(x_pos, y_pos, new_col) f.fill = New fill f\x = x_pos: f\y = y_pos old_col = ReadPixel(f\x, f\y) count = 1 LockBuffer While count > 0 count = 0 For f.fill = Each fill temp = ReadPixel(f\x, f\y) If temp = old_col WritePixelFast f\x, f\y, new_col x_pos = f\x: y_pos = f\y ;move point left If x_pos > 0 Then f\x = x_pos -1 ;new point to the right If x_pos < GraphicsWidth()-1 f.fill = New fill f\x = x_pos +1: f\y = y_pos EndIf ;new point above If y_pos > 0 f.fill = New fill f\x = x_pos: f\y = y_pos-1 EndIf ;new point below If y_pos < GraphicsHeight()-1 f.fill = New fill f\x = x_pos: f\y = y_pos+1 EndIf Else Delete f.fill EndIf count = count + 1 Next Wend UnlockBuffer End Function -->

There are no comments for this entry. -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- (c) WidthPadding Industries 1987 661|0 -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=-
 Latest PostsAGameAWeek : 2017 - Part One rychan Mon 10:07 RIP : Neil Fingleton rockford Sun 15:31 RIP : Bill Paxton Jayenkai Sun 09:18 Happy Birthday, Pakz Jayenkai Sun 01:57 Happy Birthday, Jayenkai Krakatomato Sat 13:06 Switchmas rockford Fri 02:25 What Have You Done? - Feb 2017 zzoom Thu 22:46 Hurricane Doris vs Shed Roof rockford Thu 02:38 PIP Crap Jayenkai Wed 16:45 SSL Options Jayenkai Wed 11:31 More

 Latest Items Showcase : Infinitronrychan Mon 08:11 Blog : mini projectspinal Sun 10:13 Showcase : Blockman ReturnsJayenkai Fri 03:04 Snippet : Wall Tracing on Random Maps (rpg)rskgames Wed 22:48 Snippet : Path FollowingPakz Mon 16:25 Dev-Diary : PS2 to N64 Adapterspinal Mon 01:53 Snippet : Flowers (Jan 2017)Kuron Thu 01:13 Showcase : Clusters of Hextherevillsgames Mon 15:01 Article : Maths 101 - Episode 1: Basic Trigonometryshroom_monk Sun 14:07 Article : Maths 101 - Episode 5: Line Intersectionshroom_monk Sun 14:02 Dev-Diary : Normals and Dot productsPakz Sat 20:37 Pets : Molly On The CouchJayenkai Thu 04:32 Showcase : Between SpacePakz Sun 12:55 Snippet : Additive Particle FlamesPakz Fri 18:12 Woot : My MusicJayenkai Sat 14:20More

Who's Online
Jayenkai
Mon, at 12:49
shroom_monk
Mon, at 12:19
spinal
Mon, at 11:41
rskgames
Mon, at 10:12
rychan
Mon, at 10:07
steve_ancell
Mon, at 06:26
Krakatomato
Mon, at 04:28
rockford
Mon, at 04:25
Pakz
Sun, at 22:54
Evil Roy Ferguson
Sun, at 19:50