[][src]Static p5_sys::global::createCanvas

pub static createCanvas: CreateCanvasInternalType

Creates a canvas element in the document, and sets the dimensions of it in pixels. This method should be called only once at the start of setup. Calling createCanvas more than once in a sketch will result in very unpredictable behavior. If you want more than one drawing canvas you could use createGraphics (hidden by default but it can be shown).

The system variables width and height are set by the parameters passed to this function. If createCanvas() is not used, the window will be given a default size of 100x100 pixels.

For more ways to position the canvas, see the positioning the canvas wiki page.

Examples

function setup() {
  createCanvas(100, 50);
  background(153);
  line(0, 0, width, height);
}

Parameters

w width of the canvas

h height of the canvas

renderer? either P2D or WEBGL