FillArea()

Syntax

FillArea(x, y, BorderColor [, Color])
Description
Fill an arbitrary area starting from x,y position until the BorderColor is encountered. This is useful for filling any kind of shape.

Parameters

x, y The location at which the filling should start.
BorderColor The color which should be considered the border to stop the filling. If this parameter is set to -1 then the area defined by the color found at the (x,y) coordinates will be filled, and filling stops at any color that differs from the starting point.

On 32-bit images, the alpha channel is ignored when determining whether a pixel counts as a border pixel or not.
Color (optional) The color to be used for filling the pixels. If this parameter is not specified, the default color set with FrontColor() will be used. This color can be in RGB or RGBA format.

Return value

None.

Remarks

This command does not work with PrinterOutput().

Example

  If OpenWindow(0, 0, 0, 300, 300, "2DDrawing Example", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
    If CreateImage(0, 300, 300) And StartDrawing(ImageOutput(0))
      Box(0, 0, 300, 300, RGB(255, 255, 255))

      Circle(150, 150, 125 ,$00FF00)
      Circle(150, 150, 120 ,$FF0000)
      LineXY(30, 150, 270, 150, $FFFFFF)
      FillArea(150, 155, -1, $0000FF) ; Replace -1 by $00FF00, and compare the result

      StopDrawing() 
      ImageGadget(0, 0, 0, 300, 300, ImageID(0))
    EndIf
    
    Repeat
      Event = WaitWindowEvent()
    Until Event = #PB_Event_CloseWindow
  EndIf

See Also

FrontColor()

Supported OS

All

<- EllipticalGradient() - 2DDrawing Index - FrontColor() ->