Skip to content

Commit

Permalink
Support canvas v1 & v2 API
Browse files Browse the repository at this point in the history
  • Loading branch information
lukechilds committed Nov 14, 2017
1 parent 64cb18a commit 734cf55
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,15 @@ const defaultOptions = {
Canvas: undefined
};

// Support canvas v1 & v2 API
const createCanvas = Canvas => typeof Canvas === 'function' ? new Canvas() : Canvas.createCanvas();

// Return Promise
const mergeImages = (sources = [], options = {}) => new Promise(resolve => {
options = Object.assign({}, defaultOptions, options);

// Setup browser/Node.js specific variables
const canvas = options.Canvas ? new options.Canvas() : window.document.createElement('canvas');
const canvas = options.Canvas ? createCanvas(options.Canvas) : window.document.createElement('canvas');
const Image = options.Canvas ? options.Canvas.Image : window.Image;
if (options.Canvas) {
options.quality *= 100;
Expand Down

0 comments on commit 734cf55

Please sign in to comment.