Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »

ctx-translate-center

1.0.0 • Public • Published

ctx-translate-center

translate to the center of an html5 canvas 2d context

install

npm install ctx-translate-center

use

var center = require('ctx-translate-center');
var ctx = document.createElement('canvas').getContext('2d');

document.body.appendChild(ctx.canvas);

ctx.fillStyle = "black";
ctx.fillRect(0, 0, ctx.canvas.width, ctx.canvas.height);

center(ctx);

ctx.beginPath();
  ctx.arc(0, 0, 20, 0, Math.PI*2, false);
  ctx.fillStyle = "orange";
  ctx.fill()

results in:

circle in black rectangle

license

MIT

install

npm i ctx-translate-center

Downloadsweekly downloads

12

version

1.0.0

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability