MCPcopy Create free account
hub / github.com/outerbase/studio / interpolateColor

Function interpolateColor

src/components/chart/echart-options-builder.ts:450–471  ·  view source on GitHub ↗
(
  color1: string,
  color2: string,
  factor: number
)

Source from the content-addressed store, hash-verified

448}
449
450function interpolateColor(
451 color1: string,
452 color2: string,
453 factor: number
454): string {
455 const c1 = parseInt(color1.slice(1), 16);
456 const c2 = parseInt(color2.slice(1), 16);
457
458 const r1 = (c1 >> 16) & 0xff;
459 const g1 = (c1 >> 8) & 0xff;
460 const b1 = c1 & 0xff;
461
462 const r2 = (c2 >> 16) & 0xff;
463 const g2 = (c2 >> 8) & 0xff;
464 const b2 = c2 & 0xff;
465
466 const r = Math.round(r1 + factor * (r2 - r1));
467 const g = Math.round(g1 + factor * (g2 - g1));
468 const b = Math.round(b1 + factor * (b2 - b1));
469
470 return `#${((1 << 24) + (r << 16) + (g << 8) + b).toString(16).slice(1)}`;
471}
472
473export function generateGradientColors(
474 startColor: string,

Callers 1

generateGradientColorsFunction · 0.85

Calls 1

toStringMethod · 0.45

Tested by

no test coverage detected