const { parse_hex, format_hex, lrgb_from_any, rgb_from_any, oklab_from_any } = require("./colors.js") const white = "#ffffff" const black = "#000000" function lerp(a, b, n) { return a + (b - a) * n } function blend(a, b, n) { a = lrgb_from_any(parse_hex(a)) b = lrgb_from_any(parse_hex(b)) return format_hex({ mode: "lrgb", r: lerp(a.r, b.r, n), g: lerp(a.g, b.g, n), b: lerp(a.b, b.b, n) }) } function multiply_luminance(hex, m) { let oklab = oklab_from_any(parse_hex(hex)) oklab.l = Math.max(0, Math.min(1, oklab.l * m)) return format_hex(oklab) } function add_luminance(hex, m) { let oklab = oklab_from_any(parse_hex(hex)) oklab.l = Math.max(0, Math.min(1, oklab.l + m)) return format_hex(oklab) } function make_3d_colors(base) { return [ base, multiply_luminance(base, 0.9), multiply_luminance(base, 0.8), multiply_luminance(base, 0.7), multiply_luminance(base, 0.4) ] } function make_2d_colors(base) { return [ base, multiply_luminance(base, 1.2), multiply_luminance(base, 0.8), multiply_luminance(base, 0.4) ] } function make_2d_colors_add(base) { return [ base, add_luminance(base, 0.2), add_luminance(base, -0.2), add_luminance(base, -0.5), ] } function print(x) { console.log(x) } function gencss(color, sel) { let [ bg, hi, lo, sh ] = make_2d_colors(color) print(`${sel} { border-color: ${hi} ${lo} ${lo} ${hi}; box-shadow: 0 0 0 1px ${sh}, 1px 2px 4px #0008; }`) } gencss("#efebea", ".amphitheater, .basilica, .limes") gencss("#ed1b2f", ".red") gencss("#a0caec", ".blue") gencss("#ffe175", ".yellow") gencss("#80b563", ".green") gencss("#c3bc8e", ".alamanni") gencss("#9cb4be", ".franks") gencss("#3a9cd6", ".goths") gencss("#f99d1c", ".nomads") gencss("#8e5ca6", ".sassanids") gencss("#b8b996", ".rival") gencss("#e3dedc", ".neutral") gencss("#f0f0f0", ".militia") gencss("#f0f0f0", ".legion") gencss("#6e6e6e", ".no_place_governor") gencss("#f3ddbd", "body.tint .militia") gencss("#f4cccd", "body.tint .legion.reduced") gencss("#444444", ".dice.black") gencss("#eeeeee", ".dice.white")