MCPcopy Index your code
hub / github.com/darkreader/darkreader / rgbToString

Function rgbToString

src/utils/color.ts:128–134  ·  view source on GitHub ↗
(rgb: RGBA)

Source from the content-addressed store, hash-verified

126}
127
128export function rgbToString(rgb: RGBA): string {
129 const {r, g, b, a} = rgb;
130 if (a != null && a < 1) {
131 return `rgba(${toFixed(r)}, ${toFixed(g)}, ${toFixed(b)}, ${toFixed(a, 2)})`;
132 }
133 return `rgb(${toFixed(r)}, ${toFixed(g)}, ${toFixed(b)})`;
134}
135
136export function rgbToHexString({r, g, b, a}: RGBA): string {
137 return `#${(a != null && a < 1 ? [r, g, b, Math.round(a * 255)] : [r, g, b]).map((x) => {

Callers 2

modifyColorWithCacheFunction · 0.90
color.tests.tsFile · 0.90

Calls 1

toFixedFunction · 0.85

Tested by

no test coverage detected