larvaworld.lib.model.modules.rot_surface

Classes

RotSurface

Rotatable surface object for 2D visualization.

RotTriangle

Rotatable triangle visualization object.

LightSource

Light source object for sensor detection.

Module Contents

class larvaworld.lib.model.modules.rot_surface.RotSurface(x: float, y: float, direction: float, surf: Any, **kwargs: Any)

Bases: larvaworld.lib.model.Object

Rotatable surface object for 2D visualization.

Base class for drawable objects with position, direction, and pygame surface rendering capabilities.

Attributes:

x: Object x-coordinate position. y: Object y-coordinate position. direction: Orientation in radians. surf: pygame Surface for rendering. speed: Movement speed (default: 0).

Example:
>>> rot_obj = RotSurface(
...     x=100, y=100,
...     direction=0.0,
...     surf=my_surface
... )
x
y
direction
surf
speed = 0
step() None
draw(viewer: Any) None
class larvaworld.lib.model.modules.rot_surface.RotTriangle(x: float, y: float, size: int, color_fg: Tuple[int, int, int], color_bg: Tuple[int, int, int], direction: float)

Bases: RotSurface

Rotatable triangle visualization object.

Renders a triangle shape with specified size and colors, commonly used for representing robots or agents in simulation.

Attributes:

size: Triangle size in pixels. color_fg: Foreground RGB color tuple. color_bg: Background RGB color tuple (transparent).

Example:
>>> triangle = RotTriangle(
...     x=50, y=50, size=20,
...     color_fg=(255, 0, 0),
...     color_bg=(0, 0, 0),
...     direction=1.57
... )
size
color_fg
color_bg
surf
class larvaworld.lib.model.modules.rot_surface.LightSource(x: float, y: float, emitting_power: int, color_fg: Tuple[int, int, int] = util.Color.YELLOW, color_bg: Tuple[int, int, int] = util.Color.BLACK, **kwargs: Any)

Bases: RotSurface

Light source object for sensor detection.

Visualizes light sources in simulation environment, detected by LightSensor instances with intensity based on distance.

Attributes:

emitting_power: Light intensity/size. color_fg: Foreground color (default: YELLOW). color_bg: Background color (default: BLACK). size: Visual size (equals emitting_power).

Example:
>>> light = LightSource(
...     x=200, y=200,
...     emitting_power=30,
...     color_fg=(255, 255, 0)
... )
emitting_power
color_fg
color_bg
size
label = None
surf
get_saved_scene_repr() str