How can I convert Hexadecimal to RGB Color and vice-versa?
    Marcone 
    marcone at email.com
       
    Tue Nov 24 01:02:41 UTC 2020
    
    
  
// Função hex2rgb()
uint hex2rgb(string hexcolor) nothrow {
	try {
		uint value;
		hexcolor.stripLeft("#").formattedRead!"%x"(value);
		return value;
	} catch(Throwable){return 0;}
}
// Função rgb2hex()
string rgb2hex(uint rgbcolor) nothrow {
	try {
		return "#%s".format(toHex(cast(const(BigInt)) rgbcolor));
	} catch(Throwable){return "";}
}
    
    
More information about the Digitalmars-d-learn
mailing list