canvas-styles

0.0.1 • Public • Published

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
	

Dependents (0)

Package Sidebar

Install

npm i canvas-styles

Weekly Downloads

1

Version

0.0.1

License

MIT

Last publish

Collaborators

  • rb-lab