|
@ -7,12 +7,15 @@ const defaultOptions = { |
|
|
Canvas: undefined |
|
|
Canvas: undefined |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
// Support canvas v1 & v2 API
|
|
|
|
|
|
const createCanvas = Canvas => typeof Canvas === 'function' ? new Canvas() : Canvas.createCanvas(); |
|
|
|
|
|
|
|
|
// Return Promise
|
|
|
// Return Promise
|
|
|
const mergeImages = (sources = [], options = {}) => new Promise(resolve => { |
|
|
const mergeImages = (sources = [], options = {}) => new Promise(resolve => { |
|
|
options = Object.assign({}, defaultOptions, options); |
|
|
options = Object.assign({}, defaultOptions, options); |
|
|
|
|
|
|
|
|
// Setup browser/Node.js specific variables
|
|
|
// 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; |
|
|
const Image = options.Canvas ? options.Canvas.Image : window.Image; |
|
|
if (options.Canvas) { |
|
|
if (options.Canvas) { |
|
|
options.quality *= 100; |
|
|
options.quality *= 100; |
|
|