/** * Calculates brightness on a scale of 0-255. * * @param color See colorStringToRgb for supported formats. */ function colorBrightness( color ) { if( typeof color === 'string' ) color = colorToRgb( color ); if( color ) { return ( color.r * 299 + color.g * 587 + color.b * 114 ) / 1000; } return null; }
gpu.createKernel( function(texture) { const pixel = texture[this.thread.y][this.thread.x]; return pixel.r; } ) .setOutput([4, 4])
/** * @private */ finalMessageWithoutProof(clientMessageResponse) { const rnonce = clientMessageResponse.r return `c=${encode64(GS2_HEADER)},r=${rnonce}` }
function onsuspended(x) { new Promise(r => r(backend.query.cursor( backend.query.cursor.rows === 1 ? x[0] : x ))).then(x => { x === END ? socket.write(frontend.Close()) : socket.write(frontend.Execute(backend.query.cursor.rows)) }).catch(err => { socket.write(frontend.Close()) backend.query.reject(err) }) }
gpu.createKernel(function(a) { const pixel = a[this.thread.y][this.thread.x]; return pixel.r * 255; }, { output: [image.width, image.height], precision: 'unsigned', argumentTypes: { a: 'HTMLImage' }, })
function end({ timeout = null } = {}) { if (ended) return ended let destroy return ended = Promise.race([ Promise.resolve(arrayTypesPromise).then(() => Promise.all(all.map(c => c.end()))) ].concat( timeout === 0 || timeout > 0 ? new Promise(r => destroy = setTimeout(() => (all.map(c => c.destroy()), r()), timeout * 1000)) : [] )) .then(() => clearTimeout(destroy)) }
drawTableBottom() { this.log(kleur.grey("└" + r("─", this.opts.width - 2) + "┘")); }
drawGauge(gstart, gstop) { const gw = this.opts.gaugeWidth; const p1 = Math.floor(gw * gstart / 100); const p2 = Math.max(Math.floor(gw * gstop / 100) - p1, 1); const p3 = Math.max(gw - (p1 + p2), 0); return [ kleur.grey("["), kleur.grey(r(".", p1)), r("■", p2), kleur.grey(r(".", p3)), kleur.grey("]") ].join(""); }
function setColorLinear( array, offset, color, intensity ) { array[ offset ] = color.r * intensity; array[ offset + 1 ] = color.g * intensity; array[ offset + 2 ] = color.b * intensity; }
gpu.createKernel(function(v) { const pixel = v[this.thread.y][this.thread.x]; this.color(pixel.r / 255, 0, 0, 255); }, { output: [width, height], graphical: true, argumentTypes: { v: 'Array2D(4)' } })
function setColorLinear( array, offset, color, intensity ) { array[ offset ] = color.r * intensity; array[ offset + 1 ] = color.g * intensity; array[ offset + 2 ] = color.b * intensity; }
gpu.createKernel(function(v) { const pixel = v[this.thread.y][this.thread.x]; this.color(pixel.r / 255, 0, 0, 255); }, { output: [width, height], graphical: true, argumentTypes: { v: 'Array2D(4)' } })