Smooth Button Fade using Hue & Timers Script
from
WinCustomize Forums
This is a work in progress so, be gentle. I was at a website last week when it occured to me a smoother mouse over transition could be had be scripting image settings to a timer.
Complete script will be at the end of this post. First, we start with a basic red object:
Next we set up the hue settings When we load the object the colour would then be:

Next we will set up our state changes & the relevant timers:
Initial Fade will look like this:
Final Colour should be similar to this:
Dim hueAway
Dim hueOver
Dim hueDown
'Called when the script is executed
Sub Object_OnScriptEnter
hueAway = 100
hueOver = 124
hueDown = 135
'Sets Object Hue on load
Object.Hue = hueAway
End Sub
Sub Object_OnStateChange(state)
If state="Mouse over" Then
Object.SetTimer 100, 75
Else
If state="Mouse away" Then
Object.SetTimer 200, 75
Else
If state="Mouse up" Then
Object.Hue = hueAway
Else
If state="Mouse down" Then
Object.Hue = hueDown
End If
End If
End If
End If
End Sub
'Increase the hue until it reaches the hueover aka Target Mouse Over colour
Sub Object_OnTimer100
If Object.Hue => hueAway Then
If Object.Hue <=hueOver Then
Object.Hue = Object.Hue + 2
Else
Object.SetTimer 200, 75
Object.KillTimer 100
End If
End If
End Sub
'Decreases the hue until it returns to away state colour
Sub Object_OnTimer200
If Object.Hue => hueOver Then
Object.Hue = Object.Hue - 2
Else
Object.KillTimer 200
End If
End Sub
'Called when the script is terminated
Sub Object_OnScriptExit
Object.KillTimer 100
Object.KillTimer 200
End Sub
Basically, you end up with smooth slow fade. Now you should notice why I indicate this is a work in progress as the colours don't match up exactly due to the simplicity of the script. I'm working on a more advance version based on the sliding object script from the gallery and will post the object when or if completed.
Complete script will be at the end of this post. First, we start with a basic red object:
Next we set up the hue settings When we load the object the colour would then be:

Next we will set up our state changes & the relevant timers:
Initial Fade will look like this:
Final Colour should be similar to this:
Dim hueAway
Dim hueOver
Dim hueDown
'Called when the script is executed
Sub Object_OnScriptEnter
hueAway = 100
hueOver = 124
hueDown = 135
'Sets Object Hue on load
Object.Hue = hueAway
End Sub
Sub Object_OnStateChange(state)
If state="Mouse over" Then
Object.SetTimer 100, 75
Else
If state="Mouse away" Then
Object.SetTimer 200, 75
Else
If state="Mouse up" Then
Object.Hue = hueAway
Else
If state="Mouse down" Then
Object.Hue = hueDown
End If
End If
End If
End If
End Sub
'Increase the hue until it reaches the hueover aka Target Mouse Over colour
Sub Object_OnTimer100
If Object.Hue => hueAway Then
If Object.Hue <=hueOver Then
Object.Hue = Object.Hue + 2
Else
Object.SetTimer 200, 75
Object.KillTimer 100
End If
End If
End Sub
'Decreases the hue until it returns to away state colour
Sub Object_OnTimer200
If Object.Hue => hueOver Then
Object.Hue = Object.Hue - 2
Else
Object.KillTimer 200
End If
End Sub
'Called when the script is terminated
Sub Object_OnScriptExit
Object.KillTimer 100
Object.KillTimer 200
End Sub
Basically, you end up with smooth slow fade. Now you should notice why I indicate this is a work in progress as the colours don't match up exactly due to the simplicity of the script. I'm working on a more advance version based on the sliding object script from the gallery and will post the object when or if completed.
