@@ -590,12 +590,18 @@ def __init__(
590590 self , data : MeshData , clipping = None , colors : list | None = None , label = "MeshElements2d"
591591 ):
592592 super ().__init__ (data , label = label , clipping = clipping )
593+
594+ def get_color (fd ):
595+ color = [int (ci * 255 ) for ci in fd .color ]
596+ if len (color ) == 3 :
597+ color = color + [255 ]
598+ return color
593599 if colors is None :
594600 mesh = data .mesh
595- colors = [[ int ( ci * 255 ) for ci in fd . color ] for fd in mesh .FaceDescriptors ()]
596- self .gpu_objects .colormap = Colormap (colormap = colors , minval = - 0.5 , maxval = len (colors ) - 0.5 )
601+ colors = [get_color ( fd ) for fd in mesh .FaceDescriptors ()]
602+ self .gpu_objects .colormap = Colormap (colormap = colors , minval = 0 , maxval = len (colors )- 1 )
597603 self .gpu_objects .colormap .discrete = 0
598- self .gpu_objects .colormap .n_colors = 4 * len (colors )
604+ self .gpu_objects .colormap .n_colors = len (colors )
599605
600606 @property
601607 def colormap (self ):
@@ -731,8 +737,8 @@ def __init__(self, data: MeshData, clipping=None, colors: list | None = None, sy
731737 if colors is None :
732738 colors = [[255 , 0 , 0 , 255 ] for _ in range (len (data .ngs_mesh .GetMaterials ()))]
733739 self .gpu_objects .colormap = Colormap (colormap = colors , minval = - 0.5 , maxval = len (colors ) - 0.5 )
734- self .gpu_objects .colormap .discrete = 0
735- self .gpu_objects .colormap .n_colors = 4 * len (colors )
740+ self .gpu_objects .colormap .discrete = 1
741+ self .gpu_objects .colormap .n_colors = len (colors )
736742 self .symmetry = symmetry
737743
738744 @property
0 commit comments