Adding a Hue Changer
Friday, January 16, 2009 by Tailsgirl | Discussion: DesktopX Tutorials
I know it's probably simple, but Roman, or sViz, is there a script you could write up for something like this? that would rock!
Edit: I found a tutorial by sViz, but that makes the whole object the actual shifter, which is cool but I need a seperate object to control the hue of the main one
Reply #2 Saturday, January 17, 2009 1:03 AM
Alternatively you don't have to use a slider. You could have just one button. Here's a simpler version of a script I used recently. It shifts the hue when you click or hold down the button. Just change the name of the target object:
'Called when L-click is pressed
Function Object_OnLButtonDown(x,y)
Object.SetTimer 2, 10
End Function
Sub Object_OnTimer2
increment = 2 '--Set How much to shift the hue
Set obj = DesktopX.Object("target") '--Set Name of target object
If obj.Hue < 255 Then
obj.Hue = obj.Hue + increment
Else
obj.Hue = 0
End If
End Sub
'Called when L-click is released
Function Object_OnLButtonUp(x, y, dragged)
object.KillTimer 2
End Function
That's the one I wanted hon, thanks so much, you're a Wiz, sViz, hehe that rythmes
Reply #4 Saturday, January 17, 2009 2:09 AM
TG in the Widgets you are making. open one Without DX loaded,right click on it, in the menu select "properties". You will see by default they have a hue slider built in. If thats what your looking for
Reply #5 Saturday, January 17, 2009 2:15 AM
lol HG I know hon, thanks, but I meant one to add to a widget, so people wouldn't have to go to properties
Reply #6 Saturday, January 17, 2009 2:18 AM
ok cool... figured Id give a heads up just in case you din't know there was one in Properties.
Reply #7 Saturday, January 17, 2009 2:24 AM
LOL HG, I've made so many, hehe, if I make another clock, I swear I'm gonna start ticking
Reply #8 Wednesday, February 4, 2009 4:38 AM
looks interesting... i didn't figure out how to use the scripts (let's say the second one for example). How to apply it? would be nice even to make even a tutorial.. Very usefull to have a hue changer on anything ...
Reply #9 Wednesday, February 4, 2009 5:23 AM
Make two new objects.
Step 1..
Right click on any one. Then on properties. Then in line of script, click New.
Copy and paste the script.
Step 2..
Right click on the other. Then on properties. Then on Summary.
Then in line of Object id, click "unassigned" and write 'target' there.
Setp 3..
Click on object 1.. and click again... you may be seeing some changes in color of object 2.
Step 4..
This is not required.
Delete object 2 and assign in object 1, the 'object id' as 'target'
Now click several times on itself...It changes its own color(hue)..
If you dont want to assign object id as target then, you will have to replace, 'target' in script with 'yourobjectid'
Reply #10 Wednesday, February 4, 2009 5:41 AM
Two more hue-shift scripts are here in main post and reply 14.
The script in main post will change hue when its clicked to 7 units.
The script in reply 14 will change hue automatcally when the object is in use.
Both the scripts are internal ie they will affect the objects in which you will paste them.
Reply #11 Wednesday, February 4, 2009 5:51 AM
wow, thanx superman !!! that's really super !!! so much usefull info. , i'll try to follow and use the scripts and see how it works.
Reply #12 Wednesday, February 4, 2009 6:14 AM
Right click on any one. Then on properties. Then in line of script, click New.
where exactly? i'm not sure.. i'd like to try the script from reply #14 (for example)
Reply #14 Wednesday, February 4, 2009 7:23 AM
If you take the script from reply 14 then you have to make just one object because its an internal script.
There was a problem in selecting that script. You can take that from this post..look in blue text..
1.Right-Click on any desktopX object..anywhere. Then on properties.
2. Then on New in front of Script. You will get like this...DesktopX Script Editor.
Delete all that text(script) from DesktopX Script Editor and
Copy-paste this new script from reply 14.
Dim Speed, blnActive
Speed=1000 ' This is the time in milliseconds between changing colors
blnActive=True ' Indicates to start color change on Script Enter
'Called when L-click is released
Function Object_OnLButtonUp(x, y, dragged)
If Not dragged Then
If blnActive Then
blnActive=False
Object.KillTimer 1
ElseIf Not blnActive Then
blnActive=True
Object.SetTimer 1, Speed
End If
End If
End Function
'Called when the script is executed
Sub Object_OnScriptEnter
If blnActive Then Object.SetTimer 1, Speed
End Sub
Sub Object_OnTimer1
'Store the current hue in variable
hueshift = Object.hue
'If current hue is equal to or greater than 255
'reset to 0
If hueshift => 255 Then
hueshift = 0
'If hue is not yet 255, keep adding
Else
hueshift = hueshift + 7
End If
'Set the object hue
object.hue = hueshift
End Sub
'Called when the script is terminated
Sub Object_OnScriptExit
Object.KillTimer 1
End Sub
It will look as under now.
3.Close DesktopX Script Editor. Click OK on Object Properties.
Click on Your object. It should change color now..
Please login to comment and/or vote for this skin.
Welcome Guest! Please take the time to register with us.
There are many great features available to you once you register, including:
- Richer content, access to many features that are disabled for guests like commenting on the forums and downloading skins.
- Access to a great community, with a massive database of many, many areas of interest.
- Access to contests & subscription offers like exclusive emails.
- It's simple, and FREE!
Reply #1 Saturday, January 17, 2009 12:52 AM
The script was designed to control another object. You should have 3 objects (slider_bar, slider_button, and whatever object you want to change the color.) Just change the instances of "test_object" to the name of your main object:
Dim left_pos
Dim right_pos
Sub Object_OnScriptEnter
left_pos=0
right_pos=255
desktopx.object("test_object").hue = object.Left
End Sub
Sub Object_OnDrag(mousex,mousey,newposx,newposy)
Object.top = Object.top
If newposx < left_pos Then Object.left=left_pos
If newposx > right_pos Then Object.left=right_pos
desktopx.object("test_object").hue= object.Left
End Sub
Alternatively you don't have to use a slider. You could have just one button. Here's a simpler version of a script I used recently. It shifts the hue when you click or hold down the button. Just change the name of the target object:
'Called when L-click is pressed
Function Object_OnLButtonDown(x,y)
Object.SetTimer 2, 10
End Function
Sub Object_OnTimer2
increment = 2 '--Set How much to shift the hue
Set obj = DesktopX.Object("target") '--Set Name of target object
If obj.Hue < 255 Then
obj.Hue = obj.Hue + increment
Else
obj.Hue = 0
End If
End Sub
'Called when L-click is released
Function Object_OnLButtonUp(x, y, dragged)
object.KillTimer 2
End Function