larvaworld.lib.param.drawable

Classes

Viewable

Base class for all visible objects in simulation.

ViewableToggleable

Viewable object with active/inactive state and color switching.

ViewableLine

Viewable line or polyline with rendering capabilities.

Contour

Viewable closed contour (filled polygon).

Module Contents

class larvaworld.lib.param.drawable.Viewable(**kwargs)

Bases: larvaworld.lib.param.nested_parameter_group.NestedConf

Base class for all visible objects in simulation.

Provides color management, visibility toggling, and drawing infrastructure for visual entities. Subclasses implement specific drawing methods.

Attributes:

color: Color of the entity (string name or RGB tuple) visible: Whether the entity is currently visible selected: Whether the entity is selected for highlighting

Example:
>>> obj = Viewable(color='red', visible=True)
>>> obj.set_color('blue')
>>> obj.toggle_vis()
color
visible
selected
property default_color: str
set_color(color) None
set_default_color(color) None
invert_default_color() None
draw_selected(v, **kwargs) None
draw(v, **kwargs) None
toggle_vis() bool
class larvaworld.lib.param.drawable.ViewableToggleable(**kwargs)

Bases: Viewable

Viewable object with active/inactive state and color switching.

Extends Viewable with an active state that automatically switches between active and inactive colors.

Attributes:

active: Whether the entity is currently active active_color: Color when entity is active inactive_color: Color when entity is inactive

Example:
>>> obj = ViewableToggleable(active_color='red', inactive_color='blue')
>>> obj.toggle()  # Switches active state and color
active
active_color
inactive_color
update_color() None
toggle() None
class larvaworld.lib.param.drawable.ViewableLine(**kwargs)

Bases: Viewable, larvaworld.lib.param.spatial.LineExtended

Viewable line or polyline with rendering capabilities.

Combines Viewable and LineExtended to create drawable lines/polylines with configurable width, color, and closure.

Example:
>>> line = ViewableLine(vertices=[(0,0), (1,0), (1,1)], color='red')
>>> line.draw(viewer)
draw(v, **kwargs) None
class larvaworld.lib.param.drawable.Contour(**kwargs)

Bases: Viewable, larvaworld.lib.param.spatial.LineClosed

Viewable closed contour (filled polygon).

Combines Viewable and LineClosed to create drawable filled polygons with configurable color.

Example:
>>> contour = Contour(vertices=[(0,0), (1,0), (1,1), (0,1)], color='green')
>>> contour.draw(viewer)
draw(v, **kwargs) None