Hue Slider Part 2: Brightness & Contrast

Just something I learned

Well, since I got a hue slider I figured why not a brightness and contrast slider?

Things got a little trickier. But for you, all the work is done and I now present this tutorial. Again, the scripts are based on the DesktopX Develper’s Guide tutorial "Scrolling Content".


Using the same 3 objects you created last time:



test_object= default image and size
slider_bar= 260w x 30h
slider_button= 5w x 30h


Insert this script into the slider_button object
**remove the parenthesis from the ‘less than’ sign**

Dim left_pos
Dim right_pos
Dim mid_pos
Dim newposx
Dim new_bright

Sub Object_OnScriptEnter
left_pos=0
mid_pos= 127
right_pos=255
new_bright= 0+ (object.left -127)*2
Call setBrite
End Sub

Sub Object_OnDrag(mousex,mousey,newposx,newposy)
Object.top = Object.top
If newposx(<)left_pos Then Object.left=left_pos ‘--remove the parenthesis from the less than sign
If newposx>right_pos Then Object.left=right_pos
Call setBrite
End Sub

Sub setBrite
new_bright= 0+ (object.left -127) *2

If newposx< mid_pos Then desktopx.object("test_object").brightness=new_bright
If newposx= mid_pos Then desktopx.object("test_object").brightness=new_bright
If newposx> mid_pos Then desktopx.object("test_object").brightness=new_bright


End Sub


If you’re slider_bar is 90 in width use this script

Dim left_pos
Dim right_pos
Dim mid_pos
Dim newposx
Dim new_bright

Sub Object_OnScriptEnter
left_pos=0
mid_pos= 42
right_pos=85
new_bright= 0+ (object.left -42) *6
Call setBrite
End Sub

Sub Object_OnDrag(mousex,mousey,newposx,newposy)
Object.top = Object.top
If newposx (<) left_pos Then Object.left=left_pos ‘--remove the parenthesis from the less than sign
If newposx>right_pos Then Object.left=right_pos
Call setBrite
End Sub

Sub setBrite

If newposx< mid_pos Then desktopx.object("test_object").brightness=new_bright
If newposx= mid_pos Then desktopx.object("test_object").brightness=new_bright
If newposx> mid_pos Then desktopx.object("test_object").brightness=new_bright

End Sub


If you’re slider_bar is 56 in width use this script

Dim left_pos
Dim right_pos
Dim mid_pos
Dim newposx
Dim new_bright

Sub Object_OnScriptEnter
left_pos=0
mid_pos= 25
right_pos=51
new_bright= 0+ (object.left -25)*10
Call setBrite
End Sub

Sub Object_OnDrag(mousex,mousey,newposx,newposy)
Object.top = Object.top
If newposx (<) left_pos Then Object.left=left_pos ‘--remove the parenthesis from the less than sign
If newposx>right_pos Then Object.left=right_pos
Call setBrite
End Sub

Sub setBrite
new_bright= 0+ (object.left -25) *10

If newposx< mid_pos Then desktopx.object("test_object").brightness=new_bright
If newposx= mid_pos Then desktopx.object("test_object").brightness=new_bright
If newposx> mid_pos Then desktopx.object("test_object").brightness=new_bright


End Sub





How do you do a Contrast slider? Take one of the scripts above and replace object.brightness with object.contrast.

That’s it! Thanks for reading.
1,332 views 0 replies