More customization when using world.draw()

This commit is contained in:
spencerfolk
2025-01-20 12:09:44 -05:00
parent 6a9b685203
commit 8500cad9fa

View File

@@ -158,7 +158,7 @@ class World(object):
c.transform(position=(xmin, ymin, zmin)) c.transform(position=(xmin, ymin, zmin))
return list(c.artists) return list(c.artists)
def draw(self, ax, facecolor=None, edgecolor=None, alpha=0.6): def draw(self, ax, alpha=None, edgecolor=None, facecolor=None):
""" """
Draw world onto existing Axes3D axes and return artists corresponding to the Draw world onto existing Axes3D axes and return artists corresponding to the
blocks. blocks.
@@ -174,14 +174,20 @@ class World(object):
""" """
bounds_artists = self.draw_empty_world(ax) bounds_artists = self.draw_empty_world(ax)
if alpha is None:
alpha = 0.7
if edgecolor is None:
edgecolor = 'k'
block_artists = [] block_artists = []
for b in self.world.get('blocks', []): for b in self.world.get('blocks', []):
(xmin, xmax, ymin, ymax, zmin, zmax) = b['extents'] (xmin, xmax, ymin, ymax, zmin, zmax) = b['extents']
if facecolor is None: if facecolor is None:
facecolor = b.get('color', None) fc = b.get('color', None)
if edgecolor is None: else:
edgecolor = 'k' fc = facecolor
c = Cuboid(ax, xmax-xmin, ymax-ymin, zmax-zmin, alpha=alpha, linewidth=1, edgecolors=edgecolor, facecolors=facecolor) c = Cuboid(ax, xmax-xmin, ymax-ymin, zmax-zmin, alpha=alpha, linewidth=1, edgecolors=edgecolor, facecolors=fc)
c.transform(position=(xmin, ymin, zmin)) c.transform(position=(xmin, ymin, zmin))
block_artists.extend(c.artists) block_artists.extend(c.artists)
return bounds_artists + block_artists return bounds_artists + block_artists