Last active
March 24, 2016 22:22
-
-
Save CaptainPRICE/b3b4ac1900ece3e14322 to your computer and use it in GitHub Desktop.
Expression 2 - Fading color based on Z (using percentage method; mapped 0% to low, 100% to high and then converted to color - so bottom is colored darker/black and top is being colored brighter/white)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# New version/preview: https://i.imgur.com/xsq3MJ7.png | |
# Old version/preview: https://i.imgur.com/2F23MlA.png | |
if (first()) | |
{ | |
function number percentOfValueInRange(Min, Max, Value) | |
{ | |
return ((Min - Value) / (Min - Max)) * 100 | |
} | |
function number colorValueFromPercent(Low, High, Value) | |
{ | |
return round((255 * percentOfValueInRange(Low, High, Value)) / 100) | |
} | |
# On gm_flatgrass map | |
local HIGH = -12000 # Top | |
local LOW = -12700 # Bottom | |
#print(colorValueFromPercent(LOW, HIGH, -12000)) # 255 | |
#print(colorValueFromPercent(LOW, HIGH, -12185)) # 188 | |
#print(colorValueFromPercent(LOW, HIGH, -12350)) # 128 | |
#print(colorValueFromPercent(LOW, HIGH, -12610)) # 33 | |
#print(colorValueFromPercent(LOW, HIGH, -12700)) # 0 | |
local X = entity():pos():x() | |
local Y = entity():pos():y() | |
local Z = LOW | |
for (I = 1, 58) | |
{ | |
#local Z = random(LOW, HIGH) | |
holoCreate(I, vec(X, Y, Z), vec(5.0, 5.0, 1.0), ang(), vec(colorValueFromPercent(LOW, HIGH, Z), 0, 0), "models/hunter/blocks/cube025x025x025.mdl") | |
holoMaterial(I, "models/debug/debugwhite") | |
holoDisableShading(I, 1) | |
holoShadow(I, 0) | |
Z = Z + 12.0 | |
} | |
#selfDestruct() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment