getCssCanvasContext method

Gets a CanvasRenderingContext which can be used as the CSS background of an element.

CanvasRenderingContext getCssCanvasContext(
String contextId,
String name,
int width,
int height
)

Gets a CanvasRenderingContext which can be used as the CSS background of an element.

CSS:

background: -webkit-canvas(backgroundCanvas)

Generate the canvas:

var context = document.getCssCanvasContext('2d', 'backgroundCanvas',
    100, 100);
context.fillStyle = 'red';
context.fillRect(0, 0, 100, 100);

See also: