colour.geometry.primitive_grid#

colour.geometry.primitive_grid(width: float = 1, height: float = 1, width_segments: int = 1, height_segments: int = 1, axis: Literal['-x', '+x', '-y', '+y', '-z', '+z', 'xy', 'xz', 'yz', 'yx', 'zx', 'zy'] = '+z', dtype_vertices: Type[DTypeFloat] | None = None, dtype_indexes: Type[DTypeInt] | None = None) Tuple[NDArray, NDArray, NDArray][source]#

Generate vertices and indexes for a filled and outlined grid primitive.

Parameters:
  • width (float) – Width of the primitive.

  • height (float) – Height of the primitive.

  • width_segments (int) – Number of segments along the width.

  • height_segments (int) – Number of segments along the height.

  • axis (Literal['-x', '+x', '-y', '+y', '-z', '+z', 'xy', 'xz', 'yz', 'yx', 'zx', 'zy']) – Axis to which the primitive will be normal, or plane with which the primitive will be co-planar.

  • dtype_vertices (Type[DTypeFloat] | None) – numpy.dtype to use for the grid vertices. Defaults to the numpy.dtype defined by the colour.constant.DTYPE_FLOAT_DEFAULT attribute.

  • dtype_indexes (Type[DTypeInt] | None) – numpy.dtype to use for the grid indexes. Defaults to the numpy.dtype defined by the colour.constant.DTYPE_INT_DEFAULT attribute.

Returns:

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

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]]