开发者

Actionscript Build Hex String

开发者 https://www.devze.com 2022-12-20 00:34 出处:网络
basically i want to build a colour hex value using 3 decimal values. for clarities sake, the 3 decimals i have are

basically i want to build a colour hex value using 3 decimal values.

for clarities sake, the 3 decimals i have are

255 254 253

and i want to generate the hex string:

0xFFFEFD

how would i do that开发者_JAVA百科?


var red:int = 255;
var green:int = 254;
var blue:int = 253;

private function _getHexStringFromRGB($red, $green, $blue):String {
    var num:Number = ($red << 16) + ($green << 8) + $blue;
    return "0x" + num.toString(16).toUpperCase();
}

trace(getHexStringFromRGB(red, green, blue);

Bitwise shift

0

精彩评论

暂无评论...
验证码 换一张
取 消