0.0.5 • Published 7 years ago

canvas-factory v0.0.5

Weekly downloads
4
License
MIT
Repository
github
Last release
7 years ago

canvas-factory

npm version

Usage

  1. Install node-canvas.

  2. run npm install --save canvas-factory

Optional

  • Install FFmpeg if needed to save as mp4.

Example

const { createFactory } = require('canvas-factory');
const factory = createFactory({ width : 100, height : 100  });
const canvas = factory.getCanvas();
const ctx = canvas.getContext('2d');

const d = 10;
ctx.fillStyle = 'red';
ctx.fillText("H",10,50);
ctx.fillText("e",10+d,50);
ctx.fillText(false)("l",10+d*2,50); // pass false first to not addFrame this ctx
ctx.fillText("l",10+d*3,50);
ctx.fillText(false)("o",10+d*4,50); // pass false first to not addFrame this ctx
ctx.fillText("!",10+d*5,50);

factory
  .stopRecord()
  .saveGIF('test.gif')
  .saveMP4('test.mp4')
  .clearRecord()
  .startRecord()

Dependencies

node-canvas

jsgif