Created
May 12, 2022 13:51
-
-
Save daviddarnes/46f32fcfd57e0395e9e06bd3f978a313 to your computer and use it in GitHub Desktop.
Function to turn hex colour values into p3 color values
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const hexToP3 = (string) => { | |
var aRgbHex = string.replace("#", "").match(/.{1,2}/g); | |
var aRgb = [ | |
(parseInt(aRgbHex[0], 16) / 255).toFixed(2), | |
(parseInt(aRgbHex[1], 16) / 255).toFixed(2), | |
(parseInt(aRgbHex[2], 16) / 255).toFixed(2), | |
]; | |
return `color(display-p3 ${aRgb.join(" ")})`; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment