Baby X graphics are based on the BBX_Canvas element. Essentially a canvas is a blank space on which to draw graphics. You do the actual drawing with the Baby X graphics support library, the Baby X graphics context, or a graphics library of your choice.
You create a BBX_Canvas with:You then have to lay it out in the parent's "layout" callback
Now we are ready to draw. We can do this in response to ammouse click, or from the tail of our "layout" function.
We obtain the rgba buffer to the canvas, draw on it by direct memory addressing, and then flush it to the canvas object. We shouldn't use the rgba bufffer after calling bbx_canvas_flush(). There is no need to wait on a "draw" event or to regenerate the canvas on demand, and you can draw on it in response to any Baby X event.
This system means that Baby X programs can use any graphical system, as long as it can draw to rgba buffers. The rgba buffer is always 32 bit rgba, in that order in memory, and it is always aligned so it can alias to a 32 bit type.
Baby X comes with two graphics systems, the basic system designed for drawing simple graphics, and the graphics context system designed for drawing quality 2D graphics. The simple graphics system is a list of functions that operate on rgba buffers. The graphics context system requires you to create a graphics context on the buffer, issue drawing commands to it, then destroy it. Finally you flush the buffer to the canvas. The functions can also be used for off-screen drawing to memory buffers, of course.