Adding a Hue Changer

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!:thumbsup:

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 :)

19,636 views 14 replies
Reply #1 Top

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

+2 Loading…
Reply #2 Top

Quoting sViz, reply 1

 
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:blush: :grin:

Reply #3 Top

No problem. :thumbsup:  

Reply #4 Top

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 Top

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 Top

ok cool... figured Id give a heads up just in case you din't know there was one in Properties. :thumbsup:

+1 Loading…
Reply #7 Top

LOL HG, I've made so many, hehe, if I make another clock, I swear I'm gonna start tickingX| :grin:

Reply #8 Top

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 ...

+1 Loading…
Reply #9 Top

Quoting zigboom, reply 8
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 ...

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'

 

 

 

+1 Loading…
Reply #10 Top

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.

 

+2 Loading…
Reply #11 Top

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 Top

Step 1..

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 #13 Top

oh, now i see the images. thanx very much !!!

+1 Loading…
Reply #14 Top

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..

 

 

+1 Loading…