FillArea() - Fill to any border color
Posted: Sun May 09, 2004 8:39 am
Can FillArea() be modified so that giving the border paramter a value of -1 means ..
'Keep filling while the same background colour is encountered'
So, If you start a fill on a pixel with a color of 200,100,50 the fill routine will paint all neighbouring pixels matching that colour.
Try this example to see what I mean:
'Keep filling while the same background colour is encountered'
So, If you start a fill on a pixel with a color of 200,100,50 the fill routine will paint all neighbouring pixels matching that colour.
Try this example to see what I mean:
Code: Select all
Procedure FloodFill(*hdc,x,y,fillcolor)
fillbrush=CreateSolidBrush_(fillcolor)
SelectObject_(*hdc,fillbrush)
ExtFloodFill_(*hdc,x,y,GetPixel_(*hdc,x,y),#FLOODFILLSURFACE)
DeleteObject_(fillbrush)
ReleaseDC_(WindowID(),*hdc)
EndProcedure
; create image with circles and fill regions
myimage.l=CreateImage(#pb_any,160,160)
UseImage(myimage)
*dc=StartDrawing(ImageOutput())
DrawingMode(4)
Circle(50,60,40,RGB(240,230,40))
Circle(80,80,40,RGB(240,230,40))
FloodFill(*dc,30,40,RGB(120,60,180))
FloodFill(*dc,50,60,RGB(220,10,20))
FloodFill(*dc,100,100,RGB(27,190,50))
StopDrawing()
; create window
OpenWindow(0,100,180,300,300,#PB_Window_SystemMenu | #PB_Window_TitleBar,"Fill test")
; draw image to window
StartDrawing(WindowOutput())
DrawImage(UseImage(myimage),60,60)
StopDrawing()
Repeat
ev=WaitWindowEvent()
Until ev=#PB_EventCloseWindow
End