canvas-background
Advanced tools
Comparing version 0.1.0 to 0.1.1
@@ -40,3 +40,3 @@ 'use strict'; | ||
if (backgroundColour) { | ||
context.clearRect (0, 0, width, h); | ||
context.clearRect (0, 0, width, height); | ||
context.putImageData(data, 0, 0); | ||
@@ -43,0 +43,0 @@ context.globalCompositeOperation = compositeOperation; |
{ | ||
"name": "canvas-background", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"description": "A super useful function for applying a background colour to a canvas element before invoking toDataURL.", | ||
@@ -11,3 +11,3 @@ "main": "dist/canvas-background.js", | ||
"scripts": { | ||
"build": "rollup -c" | ||
"build": "rollup -c" | ||
}, | ||
@@ -30,2 +30,2 @@ "keywords": [ | ||
} | ||
} | ||
} |
@@ -6,5 +6,5 @@ # Canvas Background | ||
> **Note:** Pilfered from [Mick Chambers](http://www.mikechambers.com/blog/2011/01/31/setting-the-background-color-when-generating-images-from-canvas-todataurl/).<br /> | ||
> **Further Note:** [Likely doesn't deserve](http://www.haneycodes.net/npm-left-pad-have-we-forgotten-how-to-program/) its own npm package. | ||
> **Note:** [Likely doesn't deserve](http://www.haneycodes.net/npm-left-pad-have-we-forgotten-how-to-program/) its own npm package. | ||
> npm: npm i canvas-background --save | ||
> npm: `npm i canvas-background --save` | ||
@@ -16,6 +16,6 @@ ## Getting Started | ||
```javascript | ||
import withBackground from 'canvas-background'; | ||
import toDataURL from 'canvas-background'; | ||
const canvas = document.querySelector('canvas'); | ||
const data = withBackground(canvas, '#ffffff', { | ||
const data = toDataURL(canvas, '#ffffff', { | ||
type: 'image/jpeg', | ||
@@ -26,2 +26,4 @@ encoderOptions: 1.0 | ||
With thanks to [mickchambers.com](http://www.mikechambers.com/blog/2011/01/31/setting-the-background-color-when-generating-images-from-canvas-todataurl/). | ||
--- | ||
Thanks to [mickchambers.com](http://www.mikechambers.com/blog/2011/01/31/setting-the-background-color-when-generating-images-from-canvas-todataurl/). |
@@ -38,3 +38,3 @@ /** | ||
if (backgroundColour) { | ||
context.clearRect (0, 0, width, h); | ||
context.clearRect (0, 0, width, height); | ||
context.putImageData(data, 0, 0); | ||
@@ -41,0 +41,0 @@ context.globalCompositeOperation = compositeOperation; |
27
5638