easymunk.pyglet Module

This submodule contains helper functions to help with quick prototyping using easymunk together with pyglet.

Intended to help with debugging and prototyping, not for actual production use in a full application. The methods contained in this module is opinionated about your coordinate system and not very optimized (they use batched drawing, but there is probably room for optimizations still).

class easymunk.pyglet.DrawOptions(**kwargs)[source]

Bases: easymunk.drawing.DrawOptions

draw_circle(pos, radius, angle=0.0, outline_color=Color(255, 0, 0, 255), fill_color=Color(255, 0, 0, 255))[source]

Draw circle from position, radius, angle, and colors.

Return type

None

draw_segment(a, b, color=Color(255, 0, 0, 255))[source]

Draw simple thin segment.

Return type

None

draw_fat_segment(a, b, radius=0.0, outline_color=Color(255, 0, 0, 255), fill_color=Color(255, 0, 0, 255))[source]

Draw fat segment/capsule.

Return type

None

draw_polygon(verts, radius=0.0, outline_color=Color(255, 0, 0, 255), fill_color=Color(255, 0, 0, 255))[source]

Draw polygon from list of vertices.

Return type

None

draw_dot(size, pos, color)[source]

Draw a dot/point.

Return type

None

DRAW_COLLISION_POINTS = 4

Draw collision points.

Use on the flags property to control if collision points should be drawn or not.

DRAW_CONSTRAINTS = 2

Draw constraints.

Use on the flags property to control if constraints should be drawn or not.

DRAW_SHAPES = 1

Draw shapes.

Use on the flags property to control if shapes should be drawn or not.

property collision_point_color

The color of collisions.

Should be a tuple of 4 ints between 0 and 255 (r, g, b, a).

color_for_shape(shape)[source]
Return type

Color

property constraint_color

The color of constraints.

Should be a tuple of 4 ints between 0 and 255 (r, g, b, a).

draw_bb(bb)[source]

Draw bounding box.

Return type

None

draw_circle_shape(circle)[source]

Default implementation that draws a circular shape.

This function is not affected by overriding the draw method of shape.

Return type

None

draw_object(obj)[source]

Draw Easymunk object.

draw_poly_shape(shape)[source]

Default implementation that draws a polygonal shape.

This function is not affected by overriding the draw method of shape.

Return type

None

draw_segment_shape(shape)[source]

Default implementation that draws a segment shape.

This function is not affected by overriding the draw method of shape.

Return type

None

draw_shape(shape)[source]

Draw shape using other drawing primitives.

Return type

None

draw_vec2d(vec)[source]

Draw point from vector.

finalize_frame()[source]

Executed after debug-draw. The default implementation is a NO-OP.

property flags

Bit flags which of shapes, joints and collisions should be drawn.

By default all 3 flags are set, meaning shapes, joints and collisions will be drawn.

Example using the basic text only DebugDraw implementation (normally you would the desired backend instead, such as pygame_util.DrawOptions or pyglet_util.DrawOptions):

shape_dynamic_color = Color(52, 152, 219, 255)
shape_kinematic_color = Color(39, 174, 96, 255)
property shape_outline_color

The outline color of shapes.

Should be a tuple of 4 ints between 0 and 255 (r, g, b, a).

shape_sleeping_color = Color(114, 148, 168, 255)
shape_static_color = Color(149, 165, 166, 255)