create-canvas
wrap canvas so you can load it the same in node or the client!
Note
this is a fork of dominictarr/canvas-browserify which makes the api a function call instead of a class instantiation, getting rid of the return override of the constructor which fails in phantomjs and maybe elsewhere
Example
draw a green circle in both the browser or node.
//example.jsvar createCanvas =var dia = 200var canvas =var ctx = canvasvar centerX = canvaswidth / 2;var centerY = canvasheight / 2;var radius = dia - 5/2;ctx;ctx;ctxfillStyle = 'green';ctx;ctxlineWidth = 5;ctxstrokeStyle = '#003300';ctx;ifprocesstitle == 'browser'documentbodyelsecanvas
run it in node...
node example.js > circle.png
bundle and run in the browser
browserify example | indexhtmlify > index.html
open index.html
License
MIT