X-Git-Url: https://git.r.bdr.sh/rbdr/tomato-sauce/blobdiff_plain/a140f3add912ef4bd659c1c1e82184643be7d845..a0666be3ab58ed83ad6d622cfe2b8293c40dffbb:/lib/renderers/256_colors.js diff --git a/lib/renderers/256_colors.js b/lib/renderers/256_colors.js index e8e6e37..8fc67b2 100644 --- a/lib/renderers/256_colors.js +++ b/lib/renderers/256_colors.js @@ -1,16 +1,19 @@ 'use strict'; -// Returns a 256 color, see -// https://en.wikipedia.org/wiki/ANSI_escape_code#Colors -// under 256 colors for more info. -const TwoFiftySixColors = function (red, blue, green) { - let redValue = Math.round(red * 5 / 255); - let blueValue = Math.round(blue * 5 / 255); - let greenValue = Math.round(green * 5 / 255); +/** + * Returns a 256 color, see https://en.wikipedia.org/wiki/ANSI_escape_code#Colors + * for more info. + * + * @function 256ColorsRenderer + * @implements IRenderer + */ +module.exports = function (red, blue, green) { - let colorNumber = 16 + 36 * redValue + 6 * greenValue + blueValue; + const redValue = Math.round(red * 5 / 255); + const blueValue = Math.round(blue * 5 / 255); + const greenValue = Math.round(green * 5 / 255); - return `\x1B[48;5;${colorNumber}m`; -}; + const colorNumber = 16 + 36 * redValue + 6 * greenValue + blueValue; -module.exports = TwoFiftySixColors; + return `\x1B[48;5;${colorNumber}m`; +};