canvas-background

0.1.3 • Public • Published

Canvas Background

A super useful function for applying a background colour to a canvas element before invoking toDataURL.

Note: Pilfered from Mick Chambers.
Note: Likely doesn't deserve its own npm package.

npm: npm i canvas-background --save

Getting Started

Use canvas-background to apply a background colour to the canvas element before exporting it via toDataURL.

import toDataURL from 'canvas-background';

const canvas = document.querySelector('canvas');
const data = toDataURL(canvas, '#ffffff', {
    type: 'image/jpeg',
    encoderOptions: 1.0
})

Thanks to mickchambers.com.

Package Sidebar

Install

npm i canvas-background

Weekly Downloads

92

Version

0.1.3

License

MIT

Last publish

Collaborators

  • wildhoney