HabitatMap/AirCasting

View on GitHub
app/javascript/react/utils/hexToRGB.ts

Summary

Maintainability
A
0 mins
Test Coverage
function hexToRGBA(hex: string, opacity: number): string {
  hex = hex.replace("#", "");
  var r = parseInt(hex.substring(0, 2), 16);
  var g = parseInt(hex.substring(2, 4), 16);
  var b = parseInt(hex.substring(4, 6), 16);

  return `rgba(${r}, ${g}, ${b}, ${opacity})`;
}

export default hexToRGBA;