Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Edge color in MeshVisual #2387

Open
ManuGraiph opened this issue Sep 27, 2022 · 4 comments
Open

Edge color in MeshVisual #2387

ManuGraiph opened this issue Sep 27, 2022 · 4 comments

Comments

@ManuGraiph
Copy link

ManuGraiph commented Sep 27, 2022

Hi! I'm plotting a mesh using:

MeshV = scene.visuals.create_visual_node(visuals.MeshVisual)
m1 = MeshV(parent=view.scene)
m1.set_data(vertices=mesh.points(),faces=np.array(mesh.faces()),face_colors=color_array_here)

Now, is there any way to change the colors of the edges in the mesh (the lines connecting the triangle vertices)?

@djhoese
Copy link
Member

djhoese commented Sep 27, 2022

There is a vertex_colors keyword argument.

vispy/vispy/visuals/mesh.py

Lines 166 to 167 in 16d8c5b

vertex_colors : array-like | None
Colors to use for each vertex.

Does that handle it? Otherwise I think you'd need to make a LineVisual that has the same vertex points and control those colors. I think that's how it is done in other compound visuals (visuals that use multiple other visuals).

There are only the concepts of faces and vertices in a MeshVisual it seems.

@ManuGraiph
Copy link
Author

ManuGraiph commented Sep 27, 2022

No, i'm asking for the edge colours, not the vertex colors.

I thought maybe there was some built-in arg for it.

@djhoese
Copy link
Member

djhoese commented Sep 27, 2022

There is for other Visuals that uses Meshes like the BoxVisual where it uses a Mesh for the object then another Mesh for the edges apparently:

self._mesh = MeshVisual(vertices['position'], filled_indices,
vertex_colors, face_colors, color)
if edge_color:
self._border = MeshVisual(vertices['position'], outline_indices,
color=edge_color, mode='lines')
else:
self._border = MeshVisual()

But then you have Visuals like PolygonVisual that uses a Mesh and a Line:

self._mesh = MeshVisual()
self._border = LineVisual(method=border_method)
self._pos = pos
self._color = Color(color)
self._border_width = border_width
self._border_color = Color(border_color)
self._triangulate = triangulate
self._update()
CompoundVisual.__init__(self, [self._mesh, self._border], **kwargs)
self._mesh.set_gl_state(polygon_offset_fill=True,
polygon_offset=(1, 1), cull_face=False)
self.freeze()

@ManuGraiph
Copy link
Author

Ohh, interesting.. it seems that with the mode = 'lines' it only plots the wireframe if the mesh and then the color arg is the edge color. I'm gonna give it a try, thanks!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants