bgiCreateCanvas

Category: BGI GUI

Syntax:

bgiCreateCanvas:Int(x:Int, y:Int, width:Int, height:Int, parent:Int)


Parameters

Returns

Int



Summary

Creates a canvas: an area of a BGI window that b2d drawing goes into. Draw a frame with bgiSetActiveCanvas(canvas), b2dCls, the b2d calls, bgiFlipCanvas(canvas), then bgiSetActiveCanvas(-1).

Takes x (Int), y (Int), width (Int), height (Int) and parent (Int). It needs b2dGraphics (the main window can be hidden: BBR_WINDOW_MODE_HIDDEN). Drawing is in the canvas's own pixels. It is black until the first flip. Clicking it gives it the keyboard focus, and while it has the focus the mouse and keys go to the program as they would from the main window (see bgiGetFocusedCanvas).

Returns the canvas ID (from the same counter as gizmos), or 0 without b2dGraphics or if parent is not found.

View detailed documentation online



Example
canvas = bgiCreateCanvas(20, 20, 480, 320, window)
bgiSetActiveCanvas(canvas)
b2dCls()
; ... b2d* draw calls ...
bgiFlipCanvas(canvas)
bgiSetActiveCanvas(-1)

BambooBasic © 2026 Michael Denathorn