MCPcopy
hub / github.com/GitbookIO/gitbook / rgbArrayToHex

Function rgbArrayToHex

packages/colors/src/transformations.ts:288–296  ·  view source on GitHub ↗
(rgb: RGBColor)

Source from the content-addressed store, hash-verified

286 * Convert a RGB color set to a hex color.
287 */
288export function rgbArrayToHex(rgb: RGBColor): string {
289 return `#${rgb
290 .map((channel) => {
291 const component = channel.toString(16);
292 if (component.length === 1) return `0${component}`;
293 return component;
294 })
295 .join('')}`;
296}
297
298export function getColor(percentage: number, start: RGBColor, end: RGBColor) {
299 const rgb = end.map((channel, index) => {

Callers 3

colorScaleFunction · 0.85
getColorFunction · 0.85
colorContrastFunction · 0.85

Calls 1

toStringMethod · 0.80

Tested by

no test coverage detected