red = 51green = 255blue = 51alpha = 128htmlColor = "#%.02X%.02X%.02X" % [ red, green, blue]# htmlColor is #33FF33puts "htmlColor is #{htmlColor}"# 带透明度htmlColor += alpha.to_s(16)# htmlColor is #33FF3380puts "htmlColor is #{htmlColor}"