0.0.1 • Published 9 years ago

canvas-styles v0.0.1

Weekly downloads
3
License
MIT
Repository
github
Last release
9 years ago

Canvas Styles

Apply css-alike styles to figures drawn on canvas

Use it with Browserify or Webpack.

Installation

	$ npm install --save canvas-styles

Usage

	var canvasStyles = require();
	
	var myRectStyle = {
		fill: '#f4f4f4',
		stroke: '#122292',
		strokeWidth: 1,
		strokeStyle: 'dashed'
	}
	
	var ctx = document.getElementById('canvas').getContext('2D');
	
	ctx.rect(10, 10, 20, 20);
	
	canvasStyles.applyStyles(ctx, myRectStyle);
	
	ctx.fill();
	ctx.stroke();
	
	// and we've got a gray rectangle with dashed border