4
$\begingroup$

I have my panel with draw definition. And want define color for BGL in panel. I know that Color class exists in blender, but how to use it? How to create custom color property for my panel?enter image description here

$\endgroup$

1 Answer 1

9
$\begingroup$

The graphical representation is determined by the subtype field which is set in this example to 'COLOR'.

from bpy.props import FloatVectorProperty
...

object_color = FloatVectorProperty(  
   name="object_color",
   subtype='COLOR',
   default=(1.0, 1.0, 1.0),
   min=0.0, max=1.0,
   description="color picker"
   )
$\endgroup$
1
  • 3
    $\begingroup$ Don't forget to specify min and max for color properties (edited above). You may also be interested in subtype='COLOR_GAMMA' with gamma correction to the color. Set size=4 for RGB + Alpha. $\endgroup$
    – CodeManX
    Jan 10, 2014 at 22:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.