Skip to content

Canvas Options

Quinton Ashley edited this page Oct 1, 2024 · 2 revisions

In p5, you're stuck with the default canvas context attributes, which can't be changed. So the canvas must have an alpha layer, even if you don't need one. HDR color space and desynchronized rendering are not supported.

But q5 has its own defaults:

Q5.canvasOptions = {
	alpha: false,
	desynchronized: false,
	colorSpace: 'display-p3'
};

The "display-p3" color space will be used by default on supported devices, falling back to "srgb".

The Q5.canvasOptions object can be overridden, which will effect all q5 instances. You can also override any of these defaults by passing an options object as the fourth parameter to the createCanvas() function:

createCanvas(400, 400, '2d', {
	alpha: true
});
Clone this wiki locally