canvas-factory
v0.0.5
Published
A module to let you produce gif and mp4 via canvas animation.
Downloads
7
Readme
canvas-factory
Usage
Install node-canvas.
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()