[script] hue player color
Posted: 11 Dec 2013, 15:32
Time to share another pretty useless script, which may be fun to use for some players out there offline.
A few times I have seen people with flickering player colors, not necessarily pleasant to the eye, maybe even annoying, but somehow an interesting idea.
So I experimented with a simple script that alters the player color using a smooth transition of fully saturated colors over the hue spectrum. I think I posted part of it earlier.
A few times I have seen people with flickering player colors, not necessarily pleasant to the eye, maybe even annoying, but somehow an interesting idea.
So I experimented with a simple script that alters the player color using a smooth transition of fully saturated colors over the hue spectrum. I think I posted part of it earlier.
- {l Code}: {l Select All Code}
// hue color scripts by bonifarz (@gmx.ch) - cc-by-sa
colorbak = $playercolour
huestep = 16 // Larger step sizes give faster but coarser color transitions.
huetime = 500 // Update interval in ms. Avoid spamishly small values.
h256 = 0 // initial hue fraction in [0:255]
h6 = 0 // initial hue segment in [0:5]
enablehue = [
echo "Hue player colors enabled. Note the variables /colorstep and /colortime."
echo "Use /disablehue to restore your previous player color."
colorbak = $playercolour
iteratehue
]
setcomplete "enablehue" 1
disablehue = [
clearsleep
playercolour $colorbak
echo "Hue player colors disabled."
]
setcomplete "disablehue" 1
iteratehue = [
h256 = (+ $h256 $huestep)
if (> $h256 255 ) [
h256 = (- $h256 256)
h6 = (+ $h6 1)
if (> $h6 5) [
h6 = (- $h6 6)
]
]
playercolour (colorfromhue $h6 $h256)
sleep $huetime [ iteratehue ]
]
colorfromhue = [
// returns a saturated color for a given hue = $arg1*60° + $arg2/255*60°
hi = $arg2
hd = (- 255 $hi)
case $arg1 0 [ // red to yellow
result (+ 0xff0000 (* $hi 0x000100))
] 1 [ // yellow to green
result (+ 0x00ff00 (* $hd 0x010000))
] 2 [ // green to cyan
result (+ 0x00ff00 (* $hi 0x000001))
] 3 [ // cyan to blue
result (+ 0x0000ff (* $hd 0x000100))
] 4 [ // blue to magenta
result (+ 0x0000ff (* $hi 0x010000))
] 5 [ // magenta to red
result (+ 0xff0000 (* $hd 0x000001))
]
]