pygfx.materials.LineMaterial

class pygfx.materials.LineMaterial(thickness=2.0, thickness_space='screen', *, color=(1, 1, 1, 1), color_mode='auto', map=None, map_interpolation='linear', dash_pattern=(), dash_offset=0, aa=True, **kwargs)

Bases: Material

Basic line material.

Parameters:
  • thickness (float) – The line thickness expressed in logical pixels. Default 2.0.

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

  • color (Color) – The uniform color of the line (used depending on the color_mode).

  • color_mode (str | ColorMode) – The mode by which the line is coloured. Default ‘auto’.

  • map (Texture) – The texture map specifying the color for each texture coordinate. Optional.

  • map_interpolation (str) – The method to interpolate the color map (‘nearest’ or ‘linear’). Default ‘linear’.

  • dash_pattern (tuple) – The pattern of the dash, e.g. [2, 3]. See dash_pattern docs for details. Defaults to an empty tuple, i.e. no dashing.

  • dash_offset (float) – The offset into the dash phase. Default 0.0.

  • aa (bool) – Whether or not the line is anti-aliased in the shader. Default True.

  • kwargs (Any) – Additional kwargs will be passed to the material base class.

property color

The uniform color of the line.

property color_is_transparent

Whether the color is (semi) transparent (i.e. not fully opaque).

property aa

Whether the line’s edges are anti-aliased.

Aliasing gives prettier results by producing semi-transparent fragments at the edges. Lines thinner than one physical pixel are also diminished by making them more transparent.

Note that by default, pygfx uses SSAA to anti-alias the total renderered result. Line-based aa results in additional improvement.

Because semi-transparent fragments are introduced, it may affect how the line blends with other (semi-transparent) objects. It can also affect performance for very large datasets. In particular, when the line itself is opaque, the line is (in most blend modes) drawn twice to account for both the opaque and semi-transparent fragments.

property color_mode

The way that color is applied to the line.

See pygfx.utils.enums.ColorMode:

property thickness

The line thickness.

The interpretation depends on thickness_space. By default it is in logical pixels, but it can also be in world or model coordinates.

property thickness_space

The coordinate space in which the thickness (and dash_pattern) are expressed.

See pygfx.utils.enums.CoordSpace:

property map

The texture map specifying the color for each texture coordinate.

Can be None. The dimensionality of the map can be 1D, 2D or 3D, but should match the number of columns in the geometry’s texcoords.

property map_interpolation

The method to interpolate the colormap.

Either ‘nearest’ or ‘linear’.

property dash_pattern

The dash pattern.

A sequence of floats describing the length of strokes and gaps. The length of the sequence must be an even number. Setting to None or the empty tuple means no dashing.

For example, (5, 2, 1, 2) describes a a stroke of 5 units, a gap of 2, then a short stroke of 1, and another gap of 2. Units are relative to the line thickness (and therefore thickness_space also applies to the dash_pattern).

property dash_offset

The offset into the dash cycle to start drawing at, i.e. the phase.