# canvas-browserify

> wrap canvas module so the same code works in node or browser

Latest version **1.1.3** (published 2015-07-29) · MIT license · 0 weekly downloads

## Install

```sh
npm install canvas-browserify
pnpm add canvas-browserify
yarn add canvas-browserify
bun add canvas-browserify
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.3 |
| Published | 2015-07-29 |
| First published | 2013-06-21 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 26 |
| Author | Dominic Tarr |
| Maintainers | dominictarr, timknip |

## Links

- npm: https://www.npmjs.com/package/canvas-browserify
- Repository: https://github.com/dominictarr/canvas-browserify
- Issues: https://github.com/dominictarr/canvas-browserify/issues
- npm.io page: https://npm.io/package/canvas-browserify

## Dependencies (1)

- [canvas](https://npm.io/package/canvas.md) ^1.2.7

## Recent versions

- 1.1.3 (latest) — 2015-07-29
- 1.1.2 — 2015-07-27
- 1.1.1 — 2013-11-25
- 1.1.0 — 2013-11-18
- 1.0.5 — 2013-11-18
- 1.0.4 — 2013-07-26
- 1.0.3 — 2013-06-21

## README

# 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.

``` js
//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(process.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

---
_Source: https://npm.io/package/canvas-browserify · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
