我必须将十六进制字符串转换为十六进制整数,如下所示:
color = "0xFF00FF" #can be any color else, defined by functions
colorto = 0xFF00FF #copy of color, but from string to integer without changes
Run Code Online (Sandbox Code Playgroud)
我也可以使用RGB格式.
我不得不这样做,因为这个功能如下:
def i2s int, len
i = 1
out = "".force_encoding('binary')
max = 127**(len-1)
while i <= len
num = int/max
int -= num*max
out << (num + 1)
max /= 127
i += 1
end
out
end
Run Code Online (Sandbox Code Playgroud)
我在这里看到存在十六进制整数.有人可以帮我解决这个问题吗?