Skip to content

Channels

This page contains classes defined in hakowan.channel module.

Visual channel models for positions, glyphs, fields, and maps.

Channel dataclass

Channel base class.

Source code in hakowan/grammar/channel/channel.py
@dataclass(kw_only=True, slots=True)
class Channel:
    """Channel base class."""

    pass

Position dataclass

Bases: Channel

Map a geometry-dimensional attribute to rendered positions.

Without this channel, source mesh vertices supply positions. Use it for deformed or alternate position attributes.

Attributes:

Name Type Description
data AttributeLike

The attribute used to encode the position field.

Source code in hakowan/grammar/channel/channel.py
@dataclass(slots=True)
class Position(Channel):
    """Map a geometry-dimensional attribute to rendered positions.

    Without this channel, source mesh vertices supply positions. Use it for
    deformed or alternate position attributes.

    Attributes:
        data (AttributeLike): The attribute used to encode the position field.

    """

    data: AttributeLike

Normal dataclass

Bases: Channel

Map a geometry-dimensional attribute to surface normals.

Without this channel, Hakowan computes normals from geometry.

Attributes:

Name Type Description
data AttributeLike

The attribute used to encode the normal field.

Source code in hakowan/grammar/channel/channel.py
@dataclass(slots=True)
class Normal(Channel):
    """Map a geometry-dimensional attribute to surface normals.

    Without this channel, Hakowan computes normals from geometry.

    Attributes:
        data (AttributeLike): The attribute used to encode the normal field.

    """

    data: AttributeLike

Size dataclass

Bases: Channel

Map a scalar attribute or constant to point/curve glyph size.

world values are radii in input geometry units. scene values are visible diameter fractions of the compiled scene bounding-box diagonal. screen values are visible diameters in output pixels.

Attributes:

Name Type Description
data AttributeLike | float

Attribute or constant size value.

space Literal['world', 'scene', 'screen']

World, scene-relative, or screen-pixel sizing.

Source code in hakowan/grammar/channel/channel.py
@dataclass(slots=True)
class Size(Channel):
    """Map a scalar attribute or constant to point/curve glyph size.

    ``world`` values are radii in input geometry units. ``scene`` values are
    visible diameter fractions of the compiled scene bounding-box diagonal.
    ``screen`` values are visible diameters in output pixels.

    Attributes:
        data: Attribute or constant size value.
        space: World, scene-relative, or screen-pixel sizing.
    """

    data: AttributeLike | float
    space: Literal["world", "scene", "screen"] = "world"

VectorField dataclass

Bases: Channel

Render a vertex- or facet-domain vector attribute as curve glyphs.

The vector must have the same dimension as the source geometry.

Attributes:

Name Type Description
data AttributeLike

The attribute used to encode the vector field.

refinement_level int

The refinement level of the vector field. This parameter is used to control the density of the vector field. The default value is 0.

style CurveStyle | None

The style of the vector field. If None, the default style will be used.

end_type Literal['point', 'arrow', 'flat']

The type of the vector field end. "point" tapers the tip to zero (cone/spike); "arrow" renders a flared arrowhead; "flat" keeps a constant radius at both ends (cylinder). The default value is "point".

normalize bool

If True, every vector is rescaled to unit length so that all arrows have the same length and only encode direction. The magnitude is freed up to be mapped to another channel (e.g. size or color via hakowan.norm()). Normalization is applied before any scale attached to data, so a uniform scale on data controls the common arrow length. By default (False), arrow length is proportional to the vector magnitude. The default value is False.

Source code in hakowan/grammar/channel/channel.py
@dataclass(slots=True)
class VectorField(Channel):
    """Render a vertex- or facet-domain vector attribute as curve glyphs.

    The vector must have the same dimension as the source geometry.

    Attributes:
        data (AttributeLike): The attribute used to encode the vector field.
        refinement_level (int): The refinement level of the vector field. This parameter is used to
            control the density of the vector field. The default value is 0.
        style (CurveStyle | None): The style of the vector field. If None, the default style will
            be used.
        end_type (Literal["point", "arrow", "flat"]): The type of the vector field end.
            ``"point"`` tapers the tip to zero (cone/spike); ``"arrow"`` renders a
            flared arrowhead; ``"flat"`` keeps a constant radius at both ends
            (cylinder). The default value is ``"point"``.
        normalize (bool): If True, every vector is rescaled to unit length so
            that all arrows have the same length and only encode direction.
            The magnitude is freed up to be mapped to another channel (e.g.
            ``size`` or color via ``hakowan.norm()``). Normalization is
            applied *before* any scale attached to ``data``, so a uniform scale
            on ``data`` controls the common arrow length. By default (False),
            arrow length is proportional to the vector magnitude. The default
            value is ``False``.

    """

    data: AttributeLike
    refinement_level: int = 0
    style: CurveStyle | None = None
    end_type: Literal["point", "arrow", "flat"] = "point"
    normalize: bool = False

Covariance dataclass

Bases: Channel

Map per-point 3x3 covariance data to anisotropic point glyphs.

full=True interprets the attribute as covariance; otherwise values are its square-root transform M where covariance is M @ M.T.

Attributes:

Name Type Description
data AttributeLike

The attribute used to encode the covariance matrix.

full bool

(bool): If True, the full covariance matrix is stored in the attribute. If False, its "square root", M, is stored. The full covariance matrix is ∑ := M @ M^T. The matrix M represenst the stretch and rotation transform applied on each mark.

Source code in hakowan/grammar/channel/channel.py
@dataclass(slots=True)
class Covariance(Channel):
    """Map per-point 3x3 covariance data to anisotropic point glyphs.

    ``full=True`` interprets the attribute as covariance; otherwise values are
    its square-root transform ``M`` where covariance is ``M @ M.T``.

    Attributes:
        data (AttributeLike): The attribute used to encode the covariance matrix.
        full: (bool): If True, the full covariance matrix is stored in the attribute.
            If False, its "square root", M, is stored. The full covariance matrix is ∑ := M @ M^T.
            The matrix M represenst the stretch and rotation transform applied on each mark.

    """

    data: AttributeLike
    full: bool = False

Shape dataclass

Bases: Channel

Select and optionally orient sphere, disk, or cube point glyphs.

Attributes:

Name Type Description
base_shape Literal['sphere', 'disk', 'cube']

The base shape used to represent a point. The default value is "sphere".

orientation AttributeLike | None

The attribute used to encode the normal orientation of the shape. If None, orientation will be identity (i.e. normal along z-axis).

Source code in hakowan/grammar/channel/channel.py
@dataclass(slots=True)
class Shape(Channel):
    """Select and optionally orient sphere, disk, or cube point glyphs.

    Attributes:
        base_shape (Literal["sphere", "disk", "cube"]): The base shape used to represent a point.
            The default value is ``"sphere"``.
        orientation (AttributeLike | None): The attribute used to encode the normal orientation
            of the shape. If None, orientation will be identity (i.e. normal along z-axis).

    """

    base_shape: Literal["sphere", "disk", "cube"] = "sphere"
    orientation: Optional[AttributeLike] = None

BumpMap dataclass

Bases: Channel

Perturb surface shading normals with a scalar bump texture.

Attributes:

Name Type Description
texture TextureLike

The texture used to encode the bump map.

scale float

The scale of the bump map. The default value is 1.0.

Source code in hakowan/grammar/channel/channel.py
@dataclass(slots=True)
class BumpMap(Channel):
    """Perturb surface shading normals with a scalar bump texture.

    Attributes:
        texture (TextureLike): The texture used to encode the bump map.
        scale (float): The scale of the bump map. The default value is 1.0.

    """

    texture: TextureLike
    scale: float = 1.0

NormalMap dataclass

Bases: Channel

Perturb surface shading normals with a tangent-space normal texture.

Attributes:

Name Type Description
texture TextureLike

The texture used to encode the normal map.

Source code in hakowan/grammar/channel/channel.py
@dataclass(slots=True)
class NormalMap(Channel):
    """Perturb surface shading normals with a tangent-space normal texture.

    Attributes:
        texture (TextureLike): The texture used to encode the normal map.

    """

    texture: TextureLike