Additional canvas methods and properties

There are several additional properties you can use:

canvas.attach(element)

Attaches canvas element to element provided. appendChild is used.

canvas.setSize(width, height)

Sets the canvas size (without scaling)

canvas.rescale(sx, sy)

Sets the scale of canvas. Provide 0.5 to make it twice smaler

canvas.fit()

Sets the canvas width and height to window.innerWidth and window.innerHeight

canvas.autofit = true

set canvas.autofit to true to make canvas automatically change its size when window is resized.

canvas.addFitCss()

Adds autofit css styles to canvas element, that will stretch it to fit entire parent positioned element. Normally should be used to make canvas fit window.

canvas.setFit(autoFit, addCSS, fitNow)

Combination of autofit, fitcss and fit methods.

// will make canvas fit window and automatically rescale
canvas.setFit(true, true, true);

cdf.shorthands()

This function exports math log, cos, floor, abs, random, tan and sin to L, C, F, A, R, T, and S variables. It has no good use in real life, I believe, but is useful while mocking something up.