Hi, I'm finishing my sprite editor that I'm going to use for future project and was thinking whether or not I need a fill rutine in there. Does anyone have an easy way of doing this?
pixel fill
BlitzPlus Forums/BlitzPlus Programming/pixel fill Found these two in the Code archive:
* http://www.blitzbasic.com/codearcs/codearcs.php?code=314
* http://www.blitzbasic.com/codearcs/codearcs.php?code=50
Hope it helps...
* http://www.blitzbasic.com/codearcs/codearcs.php?code=314
* http://www.blitzbasic.com/codearcs/codearcs.php?code=50
Hope it helps...
The first one looks promising. Thanks. With a last name like I bet your from Denmark, right?
Here's another pixel flood fill routine I did a while back for you to look over...
Graphics 1024,768,32,1 SetBuffer FrontBuffer() Global screen_width = GraphicsWidth() Global screen_height = GraphicsHeight() cx = screen_width / 2 cy = screen_height / 2 r# = 10 For count = 0 To 360 * 20 x1# = cx + Cos(count) * r# y1# = cy + Sin(count) * r# If x2# > 0 And y2# > 0 Then Line x1,y1,x2,y2 x2# = x1# y2# = y1# r# = r# + .05 Next Type fill Field x Field y Field d End Type match_red = 0 match_green = 0 match_blue = 0 fill_red = 255 fill_green = 0 fill_blue = 0 floodfill(10,10,((match_red Shl 16) Or (match_green Shl 8) Or match_blue),((fill_red Shl 16) Or (fill_green Shl 8) Or fill_blue)) While Not KeyHit(1) Wend End Function floodfill(x,y,m,fc) m = ReadPixel(x,y) flood.fill = New fill flood\x = x flood\y = y done = False LockBuffer FrontBuffer() While done = False done = True For flood.fill = Each fill done = False x = flood\x y = flood\y c = ReadPixelFast(x,y) Delete flood If c = m WritePixelFast x,y,fc If y > 0 If ReadPixelFast(x,y - 1) = m flood.fill = New fill flood\x = x flood\y = y - 1 End If End If If y < screen_height - 2 If ReadPixelFast(x,y + 1) = m flood.fill = New fill flood\x = x flood\y = y + 1 End If End If If x > 0 If ReadPixelFast(x - 1,y) = m flood.fill = New fill flood\x = x - 1 flood\y = y End If End If If x < screen_width - 2 If ReadPixelFast(x + 1,y) = m flood.fill = New fill flood\x = x + 1 flood\y = y End If End If End If Next Wend UnlockBuffer FrontBuffer() End Function
I updated mine.
It no longer needs any arrays, just that type to include
there is more info on the page.
It no longer needs any arrays, just that type to include
there is more info on the page.
Something else for you to consider. A Texture Fill function I done by converting an existing Floodfill routine.
LOL, so many ways to do a simple flood fill!
Hi Syntax Error, that texture fill is great, I'll try and work that into my bitmap font editor, thanks.