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.

If the 'Color' parameter is not specified, the default color set with FrontColor() will be used. RGB() or RGBA() can be used to get a valid color value.

If the 'BorderColor' parameter is set to -1, then the area defined by the color found at the (x,y) coordinates will be filled. On 32bit images, the alpha channel is ignored when determining whether a pixel counts as a border pixel or not.

Note: 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

Supported OS

All

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