Skip to main content
variable RGBToHex
import { RGBToHex } from "https://deno.land/x/30_seconds_of_typescript@v1.0.1/util.ts";

Converts the values of RGB components to a color code.

Convert given RGB parameters to hexadecimal string using bitwise left-shift operator (<<) and toString(16), then String.padStart(6,'0') to get a 6-digit hexadecimal value.

type

(
r: number,
g: number,
b: number,
hash?: "#" | "",
) => unknown