Documentation Index | From module rabbyt.primitives.

Quad

Quad(definition)

Quad provides a convenient representation of a quadrilateral. This is useful for specifying Sprite.shape and Sprite.tex_shape.

definition can be in a number of forms:

  • A tuple with four vertexes.

    For example: ((0,1), (1,1), (1,0), (0,0)).

  • A tuple with the format (left, top, right, bottom).

    For example: (0, 1, 1, 0). You can also think of this as (x1, y1, x2, y2), giving the top-left and bottom-right corners of a rectangle.

  • A tuple in the format of pyglet's Texture.tex_coords attribute.

    (This, is a flattened tuple giving each vertex in three dimensions. The third dimension will be discarded.)

Quad has a number of properties to make modifying it easier. The width and height properties will scale the vertexes from the center, but all other properties will move all vertexes the same amount. (e.g., assigning to left will move the right side as well: the width says the same.)

Properties

bottom

The y coordinate of the bottom-most point.

height

The height between the top-most and bottom-most vertexes.

Assigning to this property will scale all vertexes from the center. So the y property will remain the same, but top and bottom properties will change.

left

The x coordinate of the left-most point.

right

The x coordinate of the right-most point.

top

The y coordinate of the top-most point.

width

The width between the left-most and right-most vertexes.

Assigning to this property will scale all vertexes from the center. So the x property will remain the same, but left and right properties will change.

x

Halfway between left and right.

xy

The coordinates of the center of the Quad.

y

Halfway between top and bottom.