Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

canvas-browserify

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

canvas-browserify

wrap canvas so you can load it the same in node or the client!

  • 1.0.3
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
84
decreased by-3.45%
Maintainers
1
Weekly downloads
 
Created
Source

canvas-browserify

wrap canvas so you can load it the same in node or the client!

Example

draw a green circle in both the browser or node.

//example.js
var Canvas = require('./')

var dia = 200
var canvas = new Canvas(dia, dia)
var ctx = canvas.getContext('2d')

var context = canvas.getContext('2d');
var centerX = canvas.width / 2;
var centerY = canvas.height / 2;
var radius = (dia - 5)/2;

context.beginPath();
context.arc(centerX, centerY, radius, 0, 2 * Math.PI, false);
context.fillStyle = 'green';
context.fill();
context.lineWidth = 5;
context.strokeStyle = '#003300';
context.stroke();

if(process.title == 'browser') {
  document.body.appendChild(canvas)
} else {
  canvas.pngStream().pipe(procoss.stdout)
}

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

FAQs

Package last updated on 21 Jun 2013

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc