0.1.3 • Published 7 years ago

canvas-background v0.1.3

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

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.