Files
vgstation13/code/libs/s_html/inverthtml.dm
DamianX 5399c3b0f3 Fixed a bunch of linter warnings (#26360)
* Fixed a bunch of linter warnings

* Fix everything, maybe break something

* Fixed Time Stop not being cast by Arcane Golems

* Fixed arguments of remove_from_storage

* Fixed gun/afterattack arguments

* Fixed gun/Fire arguments

* Fixed arguments to candle/light and mob/emote

* Fixed arguments to simple_animal/revive, simple_animal/gib, robot/drop_item, mob/flash_eyes
2020-05-03 16:06:40 -03:00

40 lines
885 B
Plaintext

//Inverts an HTML-colour string.
//I.e. "#FF0000" will become "#00FFFF".
//This will *ONLY* accept a colour in the
// form "#XXXXXX". Nothing else will work!
proc/invertHTML(HTMLstring)
if(!istext(HTMLstring))
CRASH("Given non-text argument!")
else if(length(HTMLstring) != 7)
CRASH("Given non-HTML argument!")
var/textr = copytext(HTMLstring, 2,4)
var/textg = copytext(HTMLstring, 4,6)
var/textb = copytext(HTMLstring, 6,8)
var/r = hex2num(textr)
var/g = hex2num(textg)
var/b = hex2num(textb)
textr = num2hex(255-r)
textg = num2hex(255-g)
textb = num2hex(255-b)
if(length(textr) < 2)
textr = "0[textr]"
if(length(textg) < 2)
textr = "0[textg]"
if(length(textb) < 2)
textr = "0[textb]"
return("#[textr][textg][textb]")
/*
//Testing code/sample implementation
mob/verb/test_invertHTML()
to_chat(usr, "#CC9933")
to_chat(usr, invertHTML("#CC9933"))
*/