From c0bf2b25720971a4f2a1d7a1d969efcfcf59052d Mon Sep 17 00:00:00 2001 From: Estelle Weyl Date: Thu, 18 Apr 2024 16:53:20 -0700 Subject: [PATCH] add color() function to color tool (#176) --- modules/colors.html | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/modules/colors.html b/modules/colors.html index cb106a70..70e1a197 100644 --- a/modules/colors.html +++ b/modules/colors.html @@ -77,6 +77,10 @@ HWB + + color() + + @@ -144,6 +148,19 @@ cell.textContent = `rgb(${R} ${G} ${B} / ${opacity})`; } createHSL(R, G, B, opacity); + createColorFunc(R, G, B, opacity); + } + + function createColorFunc(r, g, b, opacity) { + const cell = document.querySelector("#colorfunc td"); + const R = Number((r / 255).toFixed(2)); + const G = Number((g / 255).toFixed(2)); + const B = Number((b / 255).toFixed(2)); + if (opacity === 1) { + cell.textContent = `color(srgb ${R} ${G} ${B})`; + } else { + cell.textContent = `color(srgb ${R} ${G} ${B} / ${opacity})`; + } } function createHSL(r, g, b, opacity) {