roboball2d.rendering package

Submodules

roboball2d.rendering.pyglet_renderer module

class roboball2d.rendering.pyglet_renderer.PygletRenderer(rendering_config, robot_configs, ball_configs, callbacks=[])

Bases: object

Renders world state instances, as returned for example by roboball2d.physics.b2_world.B2World.step(). See: roboball2d.physics.world_state.WorldState.

rendering_config:
instance of roboball2d.rendering.rendering_config.RenderingConfig
robot_configs :
list of robot configurations, see roboball2d.robot.default_robot_config.DefaultRobotConfig If only one robot is managed, a configuration instance may be passed.
ball_configs:
list of ball configurations, see roboball2d.ball.ball_config.BallConfig If only one ball is managed, a configuration instance may be passed.
callbacks:
list of callback functions, which should take a world state as argument roboball2d.physics.world_state.WorldState and use pyglet API for supplementary rendering. See: robotball2d.demos.rendering_callback().
__init__(rendering_config, robot_configs, ball_configs, callbacks=[])
rendering_config:
instance of roboball2d.rendering.rendering_config.RenderingConfig
robot_configs :
list of robot configurations, see roboball2d.robot.default_robot_config.DefaultRobotConfig If only one robot is managed, a configuration instance may be passed.
ball_configs:
list of ball configurations, see roboball2d.ball.ball_config.BallConfig If only one ball is managed, a configuration instance may be passed.
callbacks:
list of callback functions, which should take a world state as argument roboball2d.physics.world_state.WorldState and use pyglet API for supplementary rendering. See: robotball2d.demos.rendering_callback().
ball_configs
mode
render(world_state, goals=[], time_step=None, wait=True)

” Renders the world state. Spawn a window if called for the first time.

world_state:
state of the world as an instance of roboball2d.physics.world_state.WorldState
goals:
list of tuple (x1, x2, (r,g,b)). For each item, a goal will be drawn on the ground, using the specified color
time_step:
allows to force a frame rate by either; - having rendering waiting a suitable amount of time (wait=True) or - skipping some frames (wait=False)
wait:
see time_step above
rendering_config
robot_configs
window

roboball2d.rendering.pyglet_utils module

roboball2d.rendering.pyglet_utils.draw_ball(center, angle, radius, n, color, line_color)
roboball2d.rendering.pyglet_utils.draw_box(center, diameter, length, phi, color)
roboball2d.rendering.pyglet_utils.draw_circle_sector(center, angle, radius, n, color, triangles_to_draw)
roboball2d.rendering.pyglet_utils.draw_racket(racket_position, racket_angle, racket_diameter, racket_thickness, racket_color)
roboball2d.rendering.pyglet_utils.draw_rod(rod_position, rod_angle, rod_diameter, rod_length, rod_color)
roboball2d.rendering.pyglet_utils.draw_vector(initial_point, vector, width, arrow_head_size, color)

roboball2d.rendering.rendering_config module

class roboball2d.rendering.rendering_config.RenderingConfig(visible_area_width, visual_height)

Bases: object

Provides rendering configuration. User code may change values of the attribute after instantiation.

visible_area_width: float
how much width (in meters) will be displayed
visual_height: float
how much height (in meters) will be displayed
background_color:
(R,G,B) (values between 0 and 1)
ground_color:
(R,G,B) (values between 0 and 1)
window :
instance with 2 attributes: width and height (in pixels)
location:
(x,y) desired location of the window, in pixels. (note that renderers may or may not be able to impose it)
__init__(visible_area_width, visual_height)

Initialize self. See help(type(self)) for accurate signature.

background_color
ground_color
location
visible_area_width
visual_height
window

Module contents