diff --git a/js/lib/color_utils.js b/js/lib/color_utils.js index 74cff36..1ed5a65 100644 --- a/js/lib/color_utils.js +++ b/js/lib/color_utils.js @@ -113,6 +113,13 @@ function pad (n) { return n } +exports.rgb255_to_hex = function (r, g, b) { + r = r.toString(16) + g = g.toString(16) + b = b.toString(16) + return `#${pad(r)}${pad(g)}${pad(b)}` +} + exports.rgb_to_hex = function (r, g, b) { r = Math.round(r * 255).toString(16) g = Math.round(g * 255).toString(16) diff --git a/js/term/themes.js b/js/term/themes.js index aa93bc1..a1b84ee 100644 --- a/js/term/themes.js +++ b/js/term/themes.js @@ -1,5 +1,5 @@ const $ = require('../lib/chibi') -const { rgb_to_hex } = require('../lib/color_utils') +const { rgb255_to_hex } = require('../lib/color_utils') const themes = exports.themes = [ [ // 0 - Tango - terminator @@ -84,14 +84,14 @@ exports.buildColorTable = function () { let redValue = red * 40 + (red ? 55 : 0) let greenValue = green * 40 + (green ? 55 : 0) let blueValue = blue * 40 + (blue ? 55 : 0) - colorTable256.push(rgb_to_hex(redValue, greenValue, blueValue)) + colorTable256.push(rgb255_to_hex(redValue, greenValue, blueValue)) } } } // colors 232-255 are a grayscale ramp, sans black and white for (let gray = 0; gray < 24; gray++) { let value = gray * 10 + 8 - colorTable256.push(rgb_to_hex(value, value, value)) + colorTable256.push(rgb255_to_hex(value, value, value)) } return colorTable256