MCPcopy
hub / github.com/streetwriters/notesnook / changeColorAlpha

Function changeColorAlpha

packages/theme/src/theme-engine/utils.ts:178–190  ·  view source on GitHub ↗
(color: string, opacity: number)

Source from the content-addressed store, hash-verified

176}
177
178function changeColorAlpha(color: string, opacity: number) {
179 //if it has an alpha, remove it
180 if (color.length > 7) color = color.substring(0, color.length - 2);
181
182 // coerce values so ti is between 0 and 1.
183 const _opacity = Math.round(Math.min(Math.max(opacity, 0), 1) * 255);
184 let opacityHex = _opacity.toString(16).toUpperCase();
185
186 // opacities near 0 need a trailing 0
187 if (opacityHex.length == 1) opacityHex = "0" + opacityHex;
188
189 return color + opacityHex;
190}

Callers 1

deriveShadeColorFunction · 0.85

Calls 1

toStringMethod · 0.45

Tested by

no test coverage detected