Geometry¶
Geometry functions.

pyrr.geometry.
create_cube
(scale=(1.0, 1.0, 1.0), st=False, rgba=False, dtype='float32', type='triangles')[source]¶ Returns a Cube reading for rendering.
Output is a tuple of numpy arrays. The first value is the vertex data, the second is the indices.
The first dimension of the vertex data contains the list of vertices. The second dimension is the vertex data.
Vertex data is always in the following order:
[x, y, z, s, t, r, g, b, a]
ST and RGBA are optional. If ST is dropped but RGBA is included the format will be:
[x, y, z, r, g, b, a]
If both ST and RGBA are dropped the format will be:
[x, y, z]
RGBA can also be of size 3 (RGB) or 4 (RGBA).
Output format is as follows:
numpy.array([ # vertex 1 [x, y, z, s, t, r, g, b, a], # vertex 2 [x, y, z, s, t, r, g, b, a], ... # vertex N [x, y, z, s, t, r, g, b, a], ], dtype = dtype)
Parameters:  st (bool,scalar,list,tuple,numpy.ndarray) –
The ST texture coordinates.
Default is False, which means ST will not be included in the array.
If True is passed, the default ST values will be provided with the bottomleft of the quad being located at ST=(0.0,0.0) and the topright being located at ST=(1.0,1.0).
If a 2d list, tuple or numpy array is passed, it must have one of the following shapes:
(2,2,), (4,2,), (6,2,),
If the shape is (2,2,), the values are interpreted as the minimum and maximum values for ST.
For example:
st=((0.1,0.3),(0.2,0.4))
S values will be between 0.1 to 0.2. T values will be between 0.3 to 0.4.
The bottom left will receive the minimum of both, and the top right will receive the maximum.
If the shape is (4,2,), the values are interpreted as being the actual ST values for the 4 vertices of each face.
The vertices are in counterclockwise winding order from the top right:
[topright, topleft, bottomleft, bottomright,]
If the shape is (6,2,), the values are interpreted as being the minimum and maximum values for each face of the cube.
The faces are in the following order:
[front, right, back, left, top, bottom,]
 rgba (bool,scalar,list,tuple,numpy.ndarray) –
The RGBA colour.
Default is False, which means RGBA will not be included in the array.
If True is passed, the default RGBA values will be provided with all vertices being RGBA=(1.0, 1.0, 1.0, 1.0).
If a 2d list, tuple or numpy array is passed, it must have one of the following shapes.:
(3,), (4,), (4,3,), (4,4,), (6,3,), (6,4,), (24,3,), (24,4,),
If the shape is (3,), the values are interpreted as being an RGB value (no alpha) to set on all vertices.
If the shape is (4,), the values are interpreted the same as the shape (3,) except the alpha value is included.
If the shape is (4,3,), the values are interpreted as being a colour to set on the 4 vertices of each face.
The vertices are in counterclockwise winding order from the top right:
[topright, topleft, bottomleft, bottomright]
If the shape is (4,4,), the values are interpreted the same as the shape (4,3,) except the alpha value is included.
If the shape is (6,3,), the values are interpreted as being one RGB value (no alpha) for each face.
The faces are in the following order:
[front, right, back, left, top, bottom,]
If the shape is (6,4,), the values are interpreted the same as the shape (6,3,) except the alpha value is included.
If the shape is (24,3,), the values are interpreted as being an RGB value (no alpha) to set on each vertex of each face (4 * 6).
The faces are in the following order:
[front, right, back, left, top, bottom,]
The vertices are in counterclockwise winding order from the top right:
[topright, topleft, bottomleft, bottomright]
If the shape is (24,4,), the values are interpreted the same as the shape (24,3,) except the alpha value is included.
 type (string) –
The type of indices to generate.
Valid values are:
['triangles', 'triangle_strip', 'triangle_fan', 'quads', 'quad_strip',]
If you just want the vertices without any index manipulation, use ‘quads’.
 st (bool,scalar,list,tuple,numpy.ndarray) –

pyrr.geometry.
create_quad
(scale=(1.0, 1.0), st=False, rgba=False, dtype='float32', type='triangles')[source]¶ Returns a Quad reading for rendering.
Output is a tuple of numpy arrays. The first value is the vertex data, the second is the indices.
The first dimension of the vertex data contains the list of vertices. The second dimension is the vertex data.
Vertex data is always in the following order:
[x, y, z, s, t, r, g, b, a]
ST and RGBA are optional. If ST is dropped but RGBA is included the format will be:
[x, y, z, r, g, b, a]
If both ST and RGBA are dropped the format will be:
[x, y, z]
RGBA can also be of size 3 (RGB) or 4 (RGBA).
Output format is as follows:
numpy.array([ # vertex 1 [x, y, z, s, t, r, g, b, a], # vertex 2 [x, y, z, s, t, r, g, b, a], ... # vertex N [x, y, z, s, t, r, g, b, a], ], dtype = dtype)
Parameters:  st (bool,scalar,list,tuple,numpy.ndarray) –
The ST texture coordinates.
Default is False, which means ST will not be included in the array.
If True is passed, the default ST values will be provided with the bottomleft of the quad being located at ST=(0.0,0.0) and the topright being located at ST=(1.0,1.0).
If a 2d list, tuple or numpy array is passed, it must have one of the following shapes:
(2,2,), (4,2,),
If the shape is (2,2,), the values are interpreted as the minimum and maximum values for ST.
For example:
st=((0.1,0.3),(0.2,0.4))
S values will be between 0.1 to 0.2. T values will be between 0.3 to 0.4.
The bottom left will receive the minimum of both, and the top right will receive the maximum.
If the shape is (4,2,), the values are interpreted as being the actual ST values for the 4 vertices of the Quad.
The vertices are in counterclockwise winding order from the top right:
[topright, topleft, bottomleft, bottomright,]
 rgba (bool,scalar,list,tuple,numpy.ndarray) –
The RGBA colour.
Default is False, which means RGBA will not be included in the array.
If True is passed, the default RGBA values will be provided with all vertices being RGBA=(1.0, 1.0, 1.0, 1.0)
If a 2d list, tuple or numpy array is passed, it must have one of the following shapes:
(3,), (4,), (4,3,), (4,4,),
If the shape is (3,), the values are interpreted as being an RGB value (no alpha) to set on all vertices.
If the shape is (4,), the values are interpreted the same as the shape (3,) except the alpha value is included.
If the shape is (4,3,), the values are interpreted as being a colour to set on the 4 vertices of the Quad.
The vertices are in counterclockwise winding order from the top right:
[topright, topleft, bottomleft, bottomright]
If the shape is (4,4,), the values are interpreted the same as the shape (4,3,) except the alpha value is included.
 type (string) –
The type of indices to generate.
Valid values are:
['triangles', 'triangle_strip', 'triangle_fan', 'quads', 'quad_strip',]
If you just want the vertices without any index manipulation, use ‘quads’.
 st (bool,scalar,list,tuple,numpy.ndarray) –