StackGenVis: Alignment of Data, Algorithms, and Models for Stacking Ensemble Learning Using Performance Metrics
https://doi.org/10.1109/TVCG.2020.3030352
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.
38 lines
878 B
38 lines
878 B
module.exports = getCanvasContext
|
|
function getCanvasContext (type, opts) {
|
|
if (typeof type !== 'string') {
|
|
throw new TypeError('must specify type string')
|
|
}
|
|
|
|
opts = opts || {}
|
|
|
|
if (typeof document === 'undefined' && !opts.canvas) {
|
|
return null // check for Node
|
|
}
|
|
|
|
var canvas = opts.canvas || document.createElement('canvas')
|
|
if (typeof opts.width === 'number') {
|
|
canvas.width = opts.width
|
|
}
|
|
if (typeof opts.height === 'number') {
|
|
canvas.height = opts.height
|
|
}
|
|
|
|
var attribs = opts
|
|
var gl
|
|
try {
|
|
var names = [ type ]
|
|
// prefix GL contexts
|
|
if (type.indexOf('webgl') === 0) {
|
|
names.push('experimental-' + type)
|
|
}
|
|
|
|
for (var i = 0; i < names.length; i++) {
|
|
gl = canvas.getContext(names[i], attribs)
|
|
if (gl) return gl
|
|
}
|
|
} catch (e) {
|
|
gl = null
|
|
}
|
|
return (gl || null) // ensure null on fail
|
|
}
|
|
|