INNER CODE UNIT · TypeScript

value

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

      const value = (hash >> (i * 8)) & 0xff;
      colour += `00${value.toString(16)}`.substring(-2);
    }
    return colour;
  }
  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…