colour.geometry.primitive_grid

colour.geometry.primitive_grid(width=1, height=1, width_segments=1, height_segments=1, axis='+z')[source]

Generates vertices and indices for a filled and outlined grid primitive.

Parameters
  • width (float, optional) – Grid width.

  • height (float, optional) – Grid height.

  • width_segments (int, optional) – Grid segments count along the width.

  • height_segments (float, optional) – Grid segments count along the height.

  • axis (unicode, optional) – {‘+z’, ‘-x’, ‘+x’, ‘-y’, ‘+y’, ‘-z’, ‘xy’, ‘xz’, ‘yz’, ‘yx’, ‘zx’, ‘zy’}, Axis the primitive will be normal to, or plane the primitive will be co-planar with.

Returns

Tuple of grid vertices, face indices to produce a filled grid and outline indices to produce an outline of the faces of the grid.

Return type

tuple

References

[Cab]

Examples

>>> vertices, faces, outline = primitive_grid()
>>> print(vertices)
[([-0.5,  0.5,  0. ], [ 0.,  1.], [ 0.,  0.,  1.], [ 0.,  1.,  0.,  1.])
 ([ 0.5,  0.5,  0. ], [ 1.,  1.], [ 0.,  0.,  1.], [ 1.,  1.,  0.,  1.])
 ([-0.5, -0.5,  0. ], [ 0.,  0.], [ 0.,  0.,  1.], [ 0.,  0.,  0.,  1.])
 ([ 0.5, -0.5,  0. ], [ 1.,  0.], [ 0.,  0.,  1.], [ 1.,  0.,  0.,  1.])]
>>> print(faces)
[[0 2 1]
 [2 3 1]]
>>> print(outline)
[[0 2]
 [2 3]
 [3 1]
 [1 0]]