I've noticed that if I query the vertex_color of points in strokes created in vertex color mode in Python, it returns values that are different than the values shown in the color picker color used to create them.

For example, I switch to vertex color mode and draw a filled stroke with a color with a medium gray (0.5, 0.5, 0.5) and strength set to 1.0 so the alpha is 1.0. If I then query the vertex_color attr on the stroke's points, it returns a value of (0.214, 0.214, 0.214, 1.0). When trying colors that approach black or white, the discrepancy is less pronounced, almost like a LUT is being applied under the hood somewhere.

I've checked that the point's pressure and strength attrs are 1.0. Stroke's hardness at 1.0. The stroke's material fill is (0.0, 0.0, 0.0, 1.0) and so is world background. Layer blend is Regular, opacity 1.0 and Use Lights off. The color management settings are sRGB/Standard/Look=None (but it doesn't appear to make a difference if I change it anyway).

I'm stumped as to where this discrepancy is coming from. Code is pretty simple but maybe I'm missing something? :

import bpy
sel_obj = None
sel_objs = bpy.context.selected_objects
if sel_objs:
    sel_obj = sel_objs[0]    
if sel_obj and sel_obj.type=='GPENCIL':    
    gpencil = sel_obj.data    
    for gp_layer in gpencil.layers:
        for gp_frame in gp_layer.frames:
            for gp_stroke in gp_frame.strokes:
                for gp_point in gp_stroke.points:
                    rgba = gp_point.vertex_color

1 Answer 1


It's a linear <-> sRGB color space difference.

>>> from mathutils import Color
>>> c = Color((0.5, 0.5, 0.5))
>>> c.from_srgb_to_scene_linear()
Color((0.21404092013835907, 0.21404096484184265, 0.21404114365577698))

Most Python APIs return color in linear space. Some color pickers use linear and some use sRGB. There is no consistent rule I can see. But if you put 0.5 0.5 0.5 into the RGB tab of a color picker and it shows 808080 in the hex tab, that means it's sRGB.

  • $\begingroup$ Makes sense. Thanks! $\endgroup$
    – blender8r
    Feb 20, 2023 at 14:20

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .