ooc colour shenanigans (#15788)
This commit is contained in:
@@ -157,10 +157,7 @@
|
||||
#undef RGB_FORMAT_SHORT
|
||||
#undef RGB_FORMAT_LONG
|
||||
|
||||
/// Makes sure the input color is text with a # at the start followed by 6 hexadecimal characters. Examples: "#ff1234", "#A38321", COLOR_GREEN_GRAY
|
||||
/proc/sanitize_ooccolor(color)
|
||||
if(length(color) != length_char(color))
|
||||
CRASH("Invalid characters in color '[color]'")
|
||||
var/list/HSL = rgb2hsl(hex2num(copytext(color, 2, 4)), hex2num(copytext(color, 4, 6)), hex2num(copytext(color, 6, 8)))
|
||||
HSL[3] = min(HSL[3],0.4)
|
||||
var/list/RGB = hsl2rgb(arglist(HSL))
|
||||
return "#[num2hex(RGB[1],2)][num2hex(RGB[2],2)][num2hex(RGB[3],2)]"
|
||||
var/static/regex/color_regex = regex(@"^#[0-9a-fA-F]{6}$")
|
||||
return findtext(color, color_regex) ? color : GLOB.normal_ooc_colour
|
||||
|
||||
Reference in New Issue
Block a user