Skip to content

Instantly share code, notes, and snippets.

@JokerMartini
Last active July 5, 2017 14:20
Show Gist options
  • Save JokerMartini/c94140c14a61dfa810c3 to your computer and use it in GitHub Desktop.
Save JokerMartini/c94140c14a61dfa810c3 to your computer and use it in GitHub Desktop.
Maxscript: Color transition from one color to another maintaining specified color gradation.
try(destroyDialog ::progressTest)catch()
rollout progressTest "Progress Test"
(
button doit "Process Scene" -- button to start processing
spinner spnSelectAmount fieldwidth:96 range:[0,512,0] type:#integer
progressbar pb color:red -- a red progress bar
on doit pressed do -- when the button is pressed...
(
objArray = geometry as array -- get all geometry objects into array
for i = 1 to objArray.count do -- and iterate through all of them
(
-- update the progress bar percentage -- for example, if there are 20 geometry objects -- and i is currently 1, you have 100.0*1/20 = 5% -- when i is 2 you have 100.0*2/20 = 10% etc...
pb.value = 100.*i/objArray.count
-- do something with the objects, like printing their names
print objArray[i].name
)
pb.value = 0
)
on spnSelectAmount changed val do
(
maxVal = 512
minVal = 0
percent = 100 * val / maxVal
pb.value = percent
k = (val as float) / maxVal
col = red * (1 - k) + black * k
pb.color = col
)
)
createDialog progressTest
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment