Box()

Syntax

Box(x, y, Width, Height [, Color])
Description
Draw a box of given dimensions on the current output. The filling mode is determined by DrawingMode(). The current output is set with StartDrawing().

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.

The RoundBox() command can be used to draw a box with rounded corners.

Example:

  If OpenWindow(0, 0, 0, 200, 200, "2DDrawing Example", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
    If CreateImage(0, 200, 200) And StartDrawing(ImageOutput(0))
      y = 0
      For x = 0 To 95 Step 10
        Box(x, y, 200-2*x, 200-2*y, RGB(Random(255), Random(255), Random(255)))
        y + 10        ; the same as y = y + 10
      Next x
      StopDrawing() 
      ImageGadget(0, 0, 0, 200, 200, ImageID(0))
    EndIf
    
    Repeat
      Event = WaitWindowEvent()
    Until Event = #PB_Event_CloseWindow
  EndIf

Supported OS

All

<- BackColor() - 2DDrawing Index - BoxedGradient() ->