Quantcast
Channel: Scripting - McNeel Forum
Viewing all articles
Browse latest Browse all 5938

Control Random Color's HSV values - particularly Saturation

$
0
0

Hey all,

Working on a Python script, and I have a Random Color assigned to a new layer – but I’d like to be able to specify ranges of its HSV values (eg. Set a Pastel-type look with Saturation=15-25)

Thinking maybe I need to find a way to define the HSV of the color, and then convert to argb…?

Snippet of script below.

Thx,
Alan

#Create Random Color

def randomcolor():
          red = int(255*random.random())
          green = int(255*random.random())
          blue = int(255*random.random())
          return Color.FromArgb(red,green,blue)

#Define new layers (with names to be used throughout script)

bbox_layer_name = rs.AddLayer("bbox"+new_element, Color.FromArgb(20, 0, 0, 0), parent=new_element)
crv_layer_name = rs.AddLayer("crv"+new_element, Color.Red, parent=new_element)
sol_layer_name = rs.AddLayer("sol"+new_element, randomcolor(), parent=new_element)

8 posts - 5 participants

Read full topic


Viewing all articles
Browse latest Browse all 5938

Trending Articles