A suite to track Project Diva score statistics and ratings / D4DJ event data.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
projectdivar/server/node_modules/canvas/browser.js

35 lines
1.0 KiB

/* globals document, ImageData */
const parseFont = require('./lib/parse-font')
exports.parseFont = parseFont
exports.createCanvas = function (width, height) {
return Object.assign(document.createElement('canvas'), { width: width, height: height })
}
exports.createImageData = function (array, width, height) {
// Browser implementation of ImageData looks at the number of arguments passed
switch (arguments.length) {
case 0: return new ImageData()
case 1: return new ImageData(array)
case 2: return new ImageData(array, width)
default: return new ImageData(array, width, height)
}
}
exports.loadImage = function (src, options) {
return new Promise(function (resolve, reject) {
const image = Object.assign(document.createElement('img'), options)
function cleanup () {
image.onload = null
image.onerror = null
}
image.onload = function () { cleanup(); resolve(image) }
image.onerror = function () { cleanup(); reject(new Error('Failed to load the image "' + src + '"')) }
image.src = src
})
}