canvas-background
v0.1.3
Published
A super useful function for applying a background colour to a canvas element before invoking toDataURL.
Downloads
715
Maintainers
Readme
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.