larvaworld.lib.param.drawable ============================= .. py:module:: larvaworld.lib.param.drawable Classes ------- .. autoapisummary:: larvaworld.lib.param.drawable.Viewable larvaworld.lib.param.drawable.ViewableToggleable larvaworld.lib.param.drawable.ViewableLine larvaworld.lib.param.drawable.Contour Module Contents --------------- .. py:class:: Viewable(**kwargs) Bases: :py:obj:`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() .. py:attribute:: color .. py:attribute:: visible .. py:attribute:: selected .. py:property:: default_color :type: str .. py:method:: set_color(color) -> None .. py:method:: set_default_color(color) -> None .. py:method:: invert_default_color() -> None .. py:method:: draw_selected(v, **kwargs) -> None .. py:method:: draw(v, **kwargs) -> None .. py:method:: toggle_vis() -> bool .. py:class:: ViewableToggleable(**kwargs) Bases: :py:obj:`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 .. py:attribute:: active .. py:attribute:: active_color .. py:attribute:: inactive_color .. py:method:: update_color() -> None .. py:method:: toggle() -> None .. py:class:: ViewableLine(**kwargs) Bases: :py:obj:`Viewable`, :py:obj:`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) .. py:method:: draw(v, **kwargs) -> None .. py:class:: Contour(**kwargs) Bases: :py:obj:`Viewable`, :py:obj:`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) .. py:method:: draw(v, **kwargs) -> None