MsgBox % HexToRGB("0xf0ffff") MsgBox % HexToRGB("0xFFFF00", "Parse") ; Input: 6 characters HEX-color. Mode can be RGB, Message (R: x, G: y, B: z) or parse (R,G,B) HexToRGB(Color, Mode="") { ; If df, d is *16 and f is *1. Thus, Rx = R*16 while Rn = R*1 Color:=regexreplace(Color,"^(0x|0X|#)") Rx := SubStr(Color, 1,1), Rn := SubStr(Color, 2,1) Gx := SubStr(Color, 3,1), Gn := SubStr(Color, 4,1) Bx := SubStr(Color, 5,1), Bn := SubStr(Color, 6,1) AllVars := "Rx|Rn|Gx|Gn|Bx|Bn" Loop, Parse, Allvars, | ; Add the Hex values (A - F) { StringReplace, %A_LoopField%, %A_LoopField%, a, 10 StringReplace, %A_LoopField%, %A_LoopField%, b, 11 StringReplace, %A_LoopField%, %A_LoopField%, c, 12 StringReplace, %A_LoopField%, %A_LoopField%, d, 13 StringReplace, %A_LoopField%, %A_LoopField%, e, 14 StringReplace, %A_LoopField%, %A_LoopField%, f, 15 } R := Rx*16+Rn, G := Gx*16+Gn, B := Bx*16+Bn If (Mode = "Message") ; Returns "R: 255 G: 255 B: 255" Out := "R:" . R . " G:" . G . " B:" . B else if (Mode = "Parse") ; Returns "255,255,255" Out := R . "," . G . "," . B else Out := R . G . B ; Returns 255255255 return Out }
声明:站内资源为整理优化好的代码上传分享与学习研究,如果是开源代码基本都会标明出处,方便大家扩展学习路径。请不要恶意搬运,破坏站长辛苦整理维护的劳动成果。本站为爱好者分享站点,所有内容不作为商业行为。如若本站上传内容侵犯了原著者的合法权益,请联系我们进行删除下架。
评论(0)