pygfx.materials.GridMaterial

class pygfx.materials.GridMaterial(*, major_step=(1.0, 1.0), minor_step=(0.1, 0.1), axis_thickness=0.0, major_thickness=2.0, minor_thickness=0.0, thickness_space='screen', axis_color='#777', major_color='#777', minor_color='#777', infinite=True, **kwargs)

Bases: Material

A Cartesian grid.

Implements “the best darn grid shader yet” a.k.a. the Prestine grid by Ben Golus.

Parameters:
  • major_step (2-tuple | float) – The step distance between the major ticks, for the first and second dimension, respectively. Default (1.0, 1.0).

  • minor_step (2-tuple | float) – The step distance between the minor ticks, for the first and second dimension, respectively. Default (0.1, 0.1).

  • axis_thickness (float) – The thickness of the axis lines. Default 0.0 (no axis lines).

  • major_thickness (float) – The thickness of the major grid lines. Default 2.0.

  • minor_thickness (float) – The thickness of the minor grid lines. Default 0.0 (no minor grid lines).

  • thickness_space (str | CoordSpace) – The coordinate space in which the thickness is expressed (‘screen’ or ‘world’). Default ‘screen’.

  • axis_color (str | tuple | Color) – The color of the axis lines. Default ‘#777’.

  • major_color (str | tuple | Color) – The color of the major grid lines. Default ‘#777’.

  • minor_color (str | tuple | Color) – The color of the minor grid lines. Default ‘#777’.

  • infinite (bool) – Whether the grid is infinite. Default True.

  • kwargs (Any) – Additional kwargs are passed to the base constructor (pygfx.materials.Material).

property major_step

The step distance between the major grid lines.

property minor_step

The step distance between the minor grid lines.

property axis_thickness

The thickness of the axis lines.

property major_thickness

The thickness of the major grid lines.

property minor_thickness

The thickness of the minor grid lines.

property thickness_space

The coordinate space in which the thicknesses are expressed.

See pygfx.utils.enums.CoordSpace:

property axis_color

The color of the axis lines.

property major_color

The color of the major grid lines.

property minor_color

The color of the minor grid lines.

property infinite

Whether the grid is infinite.

If not infinite, the grid is 1x1 in world space, scaled, rotated, and positioned with the object’s transform.

(Infinite grids are not actually infinite. Rather they move along with the camera, and are sized based on the distance between the camera and the grid.)