Created
March 30, 2018 21:29
-
-
Save sonburn/50964351128cab3e5d2703d6edcb9f19 to your computer and use it in GitHub Desktop.
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
| function hexToColor(hex,alpha) { | |
| var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex), | |
| r = parseInt(result[1],16) / 255, | |
| g = parseInt(result[2],16) / 255, | |
| b = parseInt(result[3],16) / 255, | |
| a = (typeof alpha !== 'undefined') ? alpha : 1; | |
| return NSColor.colorWithCalibratedRed_green_blue_alpha(r,g,b,a); | |
| } | |
| var color = hexToColor('000000'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment