Bitmap/Flood fill: Difference between revisions
Content added Content deleted
m (→{{header|Tcl}}: use better template) |
(→{{header|PureBasic}}: Procedure Floodfill) |
||
Line 842: | Line 842: | ||
=={{header|PureBasic}}== |
=={{header|PureBasic}}== |
||
=== built-in === |
|||
<lang PureBasic>FillArea(0,0,-1,$ff) |
<lang PureBasic>FillArea(0,0,-1,$ff) |
||
; Fills an Area in red</lang> |
; Fills an Area in red</lang> |
||
=== Iterative === |
|||
An implementation will follow, but it can be that simple. |
|||
<lang PureBasic> Procedure Floodfill(x,y,new_color) |
|||
old_color = Point(x,y) |
|||
NewList stack.POINT() |
|||
AddElement(stack()):stack()\x = x : stack()\y = y |
|||
While(LastElement(stack())) |
|||
x = stack()\x : y = stack()\y |
|||
DeleteElement(stack()) |
|||
If Point(x,y) = old_color |
|||
Plot(x, y, new_color) |
|||
AddElement(stack()):stack()\x = x : stack()\y = y +1 |
|||
AddElement(stack()):stack()\x = x : stack()\y = y -1 |
|||
AddElement(stack()):stack()\x = x +1 : stack()\y = y |
|||
AddElement(stack()):stack()\x = x -1 : stack()\y = y |
|||
EndIf |
|||
Wend |
|||
EndProcedure |
|||
If OpenWindow(0, 0, 0, 200, 200, "Floodfill Beispiel", #PB_Window_SystemMenu | #PB_Window_ScreenCentered) |
|||
StartDrawing(WindowOutput(0)) |
|||
Box(0, 0, 200, 200, RGB(255, 255, 255)) |
|||
DrawingMode(#PB_2DDrawing_Outlined ) |
|||
Circle(100, 100, 90, RGB(255 ,0,0)): Circle(120, 80, 30, RGB(255 ,0,0)): Circle(200,200, 70, RGB(255 ,0,0)) |
|||
Floodfill(40,40,RGB(0 ,255,0)) |
|||
StopDrawing() |
|||
Repeat |
|||
Event = WaitWindowEvent() |
|||
Until Event = #PB_Event_CloseWindow |
|||
EndIf</lang> |
|||
=={{header|Tcl}}== |
=={{header|Tcl}}== |