2010 October 12 / j|d|a|v|i|s|@|c|a|r|l|e|t|o|n|.|e|d|u

Body2D

A 2D rigid body that can draw a 2D mesh with rotation, translation, and scaling, and with various combinations of color and texture.

__init__(self, mesh=None, textures=[], uniforms=[])

Initializes the body with a Mesh, a list of Textures, and a list of uniform properties.

setMesh(self, mesh)

Sets the mesh. The user is responsible for its being compatible with the renderer.

getMesh(self)

Returns the mesh.

getTextures(self)

Returns the list of textures, which the user can alter (append, pop, etc.) as desired, as long as they remain compatible with the renderer.

getUniforms(self)

Returns the list of uniform properties, which the user can alter (append, pop, etc.) as desired, as long as they remain compatible with the renderer.

setPosition(self, xy)

Sets the (x, y) position.

getPosition(self)

Returns the (x, y) position.

setAngle(self, angle)

Controls the orientation by specifying a rotation angle (measured counterclockwise from the positive x-axis in radians).

getAngle(self)

Returns the orientation angle.

setScales(self, xy)

Sets the x- and y-scales to the given pair xy of floats. The default value is (1.0, 1.0).

getScales(self)

Returns the x- and y-scales as a pair of floats.

translate(self, v)

Changes the position by adding v = (dx, dy).

rotate(self, angle)

Rotates the body counterclockwise by the given angle (in radians).

revolve(self, angle, center)

Revolves the body about the given center point by the given angle; changes position but not orientation.

revolveRotate(self, angle, center)

Revolves the body about the given center point by the given angle, also adding this angle to the body's angle, so that the same side of the body always faces the center.

setResizingBehavior(self, xBehavior, yBehavior)

Sets the resizing behavior in the x- and y-directions. For each, the options are 'start' (hold position relative to the left or bottom side), 'end' (hold position relative to the right or top side), or 'fraction' (maintain the fraction of the way between the two sides).

getResizingBehavior(self)

Returns the resizing behavior (xBehavior, yBehavior) in the x- and y-directions.