Canvas-Background

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

MIT License

Downloads
884
Stars
3
Committers
1

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 Rankings
Top 11.57% on Npmjs.org
Related Projects