Blitz3D+ Command Reference

CreateCanvas ( x,y,width,height,group[,style] )

Parameters

x,y - position of the canvas's top-left corner within the group's client area

width,height - size of the canvas

group - window or gadget group that owns the canvas

style (optional) - 0: plain (default); bit 1: sunken client edge border

Description

Creates a canvas gadget you can draw on, and returns its handle.

Requires Extended language mode.

A canvas is a rectangle of real pixels inside your GUI, and it works in one of two modes. Out of the box it is a 2D canvas: point the drawing commands at it with SetBuffer CanvasBuffer(canvas), draw, then present with FlipCanvas - several 2D canvases can run at once. Or call Graphics3DCanvas to attach the Direct3D 12 renderer to it, which is how you embed a live game viewport inside an editor window.

Mouse and keyboard input over the canvas arrives through the shared event queue with EventSource set to the canvas handle, and CanvasMouseX/CanvasMouseY poll the pointer in canvas pixels. Note the two coordinate spaces: the gadget's position and size here are logical 96-DPI units, while the drawing surface is measured in physical pixels by CanvasPixelWidth and CanvasPixelHeight.

Give the canvas a SetGadgetLayout so it resizes with its window. Resizing is graceful in both modes: a 2D canvas preserves its overlapping pixels, and a 3D canvas defers the expensive swap-chain rebuild until the next FlipCanvas after the drag ends.

See it working in the 2D canvas sample, the embedded Graphics3D sample and the world editor shell sample.

See also: CanvasBuffer, FlipCanvas, Graphics3DCanvas, CanvasPixelWidth, CanvasMouseX, RenderWorldToCanvas.

Index