Hue is not expressed in percent but degree.
It seems the values above 360˚ are automatically changed, so you could give this a try.
var foreColor = new SolidColor;
var theNewValue = foreColorH + 15 - Math.random() * 30;
app.foregroundColor = foreColor;
thanks, c - that really works well. I'm trying to emulate the "hue jitter" in the brushes panel under color dynamics. Same for brightness, and also saturation. So whenever the script it executed, the hue jitters upwards or downwards just a little bit- this does the trick. The only catch is that when it shifts up or down, then the next time the code is run, it shifts again but not from the original color, but from the new color that was just shifted - I hope that makes sense. So in other words the "hue jitter" in the brushes panel keeps the original color in memory (ff0000, for example), and every time you draw a brush stroke, it jitters up or down from ff0000. This script however, jitters from ff0000 the first time you run the script, and now the color has shifted to, say, ff0202. Now, when you run the script a second time, it shifts the color from ff0202 instead of the original ff0000. This causes the jitter to eventually stray further away from ff0000 and shift through the entire color spectrum if you run it enough times. Is there a way to have it always shift from ff0000 no matter how many times you run the script?
One could store the information (the Hue value in this case) in the metadata or as a txt file and check that.
Problem is how to decide when to start wholly anew (based on the current Foreground Color).
One could use
to have one Script perform two different tasks.
Edit: Sorry, was a bit unclear, that property can be used to have a Script perform one task if the shift-key is pressed when it is started and another if the shift-key is not pressed …
I guess a more "basic" approach could be to save a Solid Color Layer (with a black Layer Mask) to store the original Color.
Deleting that Layer could then force the Script to start with the Foreground Color again.
managed to get it working - the very first step was to copy the foreground color to the clipboard by pressing ALT+F12 (this works in CC2014, I don't know about other versions). Next, the "jitter" code that you supplied is executed- and the color is shifted up or down by 15 degrees. Third, I included a "wait until left mouse button has been pressed and released"- this allows the user to paint a single brush stroke using the shifted color and then it waits until the left button is released after painting that stroke. Finally, the color which is in the clipboard (from step 1) is restored as the new foreground color (I used "Paul's External Library"- 'psClipboard64.dll' to cover that part). And now we're back to square one. Run the script a second time, and all of the above is repeated, except that your jitter code should shift the color to a different random color. So as a result, this becomes a successful reproduction of "hue jitter" in the brush panel. I've already worked in the saturation and brightness to it as well. I would love to share what I have but the only thing is that I'm using other 3rd party software along with the code to get it to work. So it's not all .jsx code and posting any other type of language here probably won't help anyone.
What I'm getting at is, thanks for the help - it works