Can this RGB color setting code be python code of HSV color setting?

Hi, We are creating a script to set the material color. What we refer to is a code that can be done with random colors.

mat.diffuse_color = random(), random(), random()

But is it possible to set this in HSV color? I try to find an API description, but I can not find it easily.

I think mat.diffuse_color is an array of three floats that represent rgb, so you will need to convert your hsv to rgb before setting it. You can use the Color class to do this:

import mathutils
col = mathutils.Color()
col.hsv = random(), random(), random()
mat.diffuse_color = col[:]

Al.

1 Like

Hi, a person with an avatar of Pikmin! =)
It looks like we’ve never played that game but it’s a relaxing game, maybe?

Thank you for telling me that cord!
However, although this can be done, the color selector of material diffuse in Blender-pop-up remains as RGB. But I will not care if this is a specification.
And it was important for us to be able to use hsv! Thank you.