1. #1
    New Member User Gallery
    Join Date
    Aug 2005
    Posts
    20

    Question 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/javascrip...onversion.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: ps_hsv3.txt

  2. #2
    Moderator User Gallery
    Join Date
    Jun 2004
    Location
    UK
    Posts
    7,679

    Default

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

  3. #3
    New Member User Gallery
    Join Date
    Aug 2005
    Posts
    20

    Default thank you!

    Omg, thanks so much 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 (?)

  4. #4
    Moderator User Gallery
    Join Date
    Jun 2004
    Location
    UK
    Posts
    7,679

    Default

    Quote Originally Posted by gamePat View Post
    Omg, thanks so much 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 (?)
    Yes, aspects of zscript are specially designed to trip you up and keep you on your toes. (I think ZScript is simply parsed left to right unless you use brackets.)

  5. #5
    Senior Member User Gallery
    Join Date
    Jan 2003
    Location
    NYC
    Posts
    1,625

    Default Hsv!

    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
    Last edited by Svengali; 12-19-11 at 06:31 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •