ZBrushCentral

HSV2RGB Script

Hi guys,
I’m working on a little script to change the color by hue, saturation and value (HSV) .
So I have 3 sliders to set the values which will be converted to the RGB values to set the color in the color menu in Zbrush.

I used the code from these examples in JavaScript and translated it to ZScript:
http://snipplr.com/view/14590
http://www.webtoolkit.info/javascript-color-conversion.html

I’m pretty sure I did everything exactly as in the the reference scripts.
The problem is, the saturation doesn’t seem to work at all and the hue only chenges in steps…kind of

What is the problem here :S ?

Script is attached:

Your values were not been calculated correctly because the correct order of operations wasn’t being followed. Inclusion of some extra brackets to force the order corrected the problem.

Omg, thanks so much :smiley: didn’t expect a solution so soon.
Works nice and smooth now.
But douh … what a problem :P, I took it for granted that ZBrush can handle proper operator preceedence rules (?) :slight_smile:

Yes, aspects of zscript are specially designed to trip you up and keep you on your toes. :wink: (I think ZScript is simply parsed left to right unless you use brackets.)

Thank you both… I’ve been looking for a script like this to move into another application. In my opinion, it’s a more logical way to design color than the ever-present and non-intuitive R, G, B sliders.

Is there another version which takes R, G, B into H, S, V? (oops, never mind, I found your original link and I’ll take a shot at rewriting R,G,B to H,S,V myself.)

Svengali