get-context

Chainable canvas context api wrapper.
Install
With Node.js:
$ npm install get-context
With Bower:
$ bower install shannonmoeller/get-context
With Component:
$ component install shannonmoeller/get-context
API
getContext(element, type)
Creates an instance of a chainable canvas context api wrapper. The type argument may be '2d' or 'webgl'. Defaults to '2d'.
var canvas = document.createElement('canvas');
var context = require('get-context')(canvas);
context
.set({
strokeStyle: '#0000ff',
lineCap: 'round'
})
.beginPath()
.arc(75, 75, 50, 0, Math.PI * 2, true)
.moveTo(110, 75)
.arc(75, 75, 35, 0, Math.PI, false)
.moveTo(65,65)
.arc(60, 65, 5, 0, Math.PI * 2, true)
.moveTo(95,65)
.arc(90, 65, 5, 0, Math.PI * 2, true)
.stroke();
.get(key)
Gets a single context property.
context.get('fillStyle');
.get(array)
Gets multiple context properties.
context.get(['fillStyle', 'strokeStyle']);
.set(key, value)
Sets a single context property.
context.set('fillStyle', '#FF0000');
.set(object)
Sets multiple context properties.
context.set({
fillStyle: '#FF0000',
strokeStyle: '#00FF00'
});
Test
$ npm test
© 2015 Shannon Moeller me@shannonmoeller.com
Licensed under MIT