Last active
July 13, 2018 03:30
-
-
Save deldersveld/0292f3871a23f2801c38572662f3120f to your computer and use it in GitHub Desktop.
DAX - Hex Color to RGB
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
Hex Color to RGB = | |
VAR HexColorValue = "#01B8AA" | |
// Do not change anything below this line | |
VAR PositionRed1 = RIGHT(LEFT(HexColorValue,2),1) | |
VAR PositionRed0 = RIGHT(LEFT(HexColorValue,3),1) | |
VAR PositionGreen1 = RIGHT(LEFT(HexColorValue,4),1) | |
VAR PositionGreen0 = RIGHT(LEFT(HexColorValue,5),1) | |
VAR PositionBlue1 = RIGHT(LEFT(HexColorValue,6),1) | |
VAR PositionBlue0 = RIGHT(LEFT(HexColorValue,7),1) | |
VAR Red1 = SWITCH(PositionRed1,"A",10,"B",11,"C",12,"D",13,"E",14,"F",15,PositionRed1) * 16 | |
VAR Red0 = SWITCH(PositionRed0,"A",10,"B",11,"C",12,"D",13,"E",14,"F",15,PositionRed0) | |
VAR Green1 = SWITCH(PositionGreen1,"A",10,"B",11,"C",12,"D",13,"E",14,"F",15,PositionGreen1) * 16 | |
VAR Green0 = SWITCH(PositionGreen0,"A",10,"B",11,"C",12,"D",13,"E",14,"F",15,PositionGreen0) | |
VAR Blue1 = SWITCH(PositionBlue1,"A",10,"B",11,"C",12,"D",13,"E",14,"F",15,PositionBlue1) * 16 | |
VAR Blue0 = SWITCH(PositionBlue0,"A",10,"B",11,"C",12,"D",13,"E",14,"F",15,PositionBlue0) | |
VAR HexColorToRGB = "RGB(" & Red1 + Red0 & "," & Green1 + Green0 & "," & Blue1 + Blue0 & ")" | |
RETURN HexColorToRGB |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment