Skip to content

color.domain

Summary

color.domain assigns a color to a complex value using its phase, magnitude, or both. Use it to color a complex plot in a way that exposes structure in the output values.

Syntax

domain(re: number, im: number, desc?: DomainColorDescriptor): Color4
const rgba = WasmGPU.color.domain(1, -2);

Parameters

Name Type Required Description
re, im number Yes Real and imaginary components.
desc DomainColorDescriptor No Mode, CPU-sampleable colormap and optional magnitude range.

Returns

Color4 - Linear RGBA. Non-finite input or magnitude returns opaque white. The same operation is exported as domainColor.

Type Details

type DomainColorMode = "domain" | "argument" | "modulus";
type DomainColorDescriptor = {
    colormap?: BuiltinColormapName | Colormap;
    mode?: DomainColorMode;
    range?: [number, number];
};

"domain" is the default. Phase selects a position on a full turn of the map, and magnitude darkens the color near zero and lightens it as magnitude increases. Zero is opaque black. "argument" uses only the phase. Both modes default to "hsv".

"modulus" uses magnitude and defaults to "viridis". Its range defaults to [0, 1] and must hold two finite numbers. Values beyond the range sample an endpoint. Equal endpoints sample the midpoint. Reversing the range reverses the lookup direction.

Example

const rgba = WasmGPU.color.domain(3, 4, { mode: "modulus", range: [0, 10] });
console.log(rgba);

See Also