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[Any, dtype[_ScalarType_co]], ndarray[Any, dtype[_ScalarType_co]], ndarray[Any, dtype[_ScalarType_co]]][source]#

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

Parameters:
  • width (float) – Grid width.

  • height (float) – Grid height.

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

  • height_segments (int) – Grid segments count along the height.

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

  • dtype_vertices (Type[DTypeFloat] | None) – numpy.dtype to use for the grid vertices, default 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, default 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 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]]