INNER CODE UNIT · TypeScript

contrastYiq

open-source-labs/Chronos · app/containers/GraphsContainer/helpers/index.ts:17

  function contrastYiq(color: string) {
    const num = parseInt(color.slice(1), 16);
    const r = (num >>> 16) & 0xff;
    const g = (num >>> 8) & 0xff;
    const b = num & 0xff;
    const yiq = (r * 299 + g * 587 + b * 114) / 1000;
    return yiq <= 50 ? stringToColour(color, recurses + 1) : color;
  }
  for (let salt = 0; salt < 5; salt++) string = hashString(string);
  return contrastYiq(string);
};

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…