Skip to content

Canvas.js

dannyx0 edited this page Aug 10, 2012 · 3 revisions

The purpose of Canvas.js is as follows:

  1. Quick and flexible method for embedding a <canvas> node.
  2. Easy access to getting / setting the canvas context.
  3. Help with small things like window resizing and pixel ratios.

Options

context		[str]		-	Context type.
container	[dom]		-	<canvas> container.
width		[num/str]	-	Canvas width. "auto" fits to container.
height		[num/str]	-	Canvas height. "auto" fits to container.
resize		[bool]		-	Should the canvas width/height be reset when the window is resized?

Quick Start

HTML

<div id="canvas"></div>

JavaScript

require(["Canvas"], function (canvas) {

	canvas.init({
		container : document.getElementById('canvas')
	});

	var ctx = canvas.context();
	// Do cool things with canvas here.

});

Clone this wiki locally