pixtreme.generate
generate
Procedural image and noise generators.
__all__ = ('ramp', 'grid', 'checkerboard', 'color_bars', 'fractal_noise', 'turbulent_noise', 'grain')
module-attribute
fractal_noise(*, width, height, scale, octaves=4, lacunarity=2.0, gain=0.5, seed=0, evolution=0.0, colorspace, gamma='linear')
Generate normalized fractal gradient noise on the GPU.
Pixel (i, j) uses centers i + 0.5 and j + 0.5 divided by
scale. seed selects a deterministic realization; None selects
one from local entropy. evolution is a continuous third-coordinate
phase shared by every octave. Octave frequencies use lacunarity and
amplitudes use gain. The weighted result is centered at 0.5 and
normalized to [0, 1] with C = sqrt(3) / 2.
Each octave uses the ordinary xy coordinate while both axes remain finite
and below 2**53, the largest double value with unit lattice precision.
If frequency growth or division by scale makes an axis non-finite or
reaches that limit, that axis evaluates at lattice origin 0.0 for the
octave. The seed-derived octave stream and finite evolution phase stay
active, giving a deterministic finite limit that may be constant along one
or both image axes.
The returned fp32 Frame reports the requested colorspace and gamma,
declares channels ("Y",), and owns a new C-contiguous allocation.
grain(*, width, height, intensity=0.1, size=1.0, monochromatic=True, seed=0, evolution=0.0, colorspace, gamma='linear')
Generate Gaussian grain with continuous spatial and evolution interpolation.
Pixel centers i + 0.5 and j + 0.5 sample a lattice whose xy spacing
is size; size 1 places one lattice realization at each pixel center.
seed selects the realization and None uses local entropy.
evolution is the continuous third-coordinate phase, with adjacent
integer phases selecting independent lattice layers. Color mode folds each
RGB channel into an independent stream.
Box-Muller Gaussian values use a three standard deviation normalization:
0.5 + intensity * 0.5 * g / 3. Output is clipped to [0, 1]; at
intensity 1 the statistical clip residual is approximately 0.27%.
The returned fp32 Frame reports the requested colorspace and gamma,
declares Y or RGB channels, and owns a new C-contiguous allocation.
turbulent_noise(*, width, height, scale, octaves=4, lacunarity=2.0, gain=0.5, seed=0, evolution=0.0, colorspace, gamma='linear')
Generate normalized absolute-value turbulent gradient noise on the GPU.
Pixel (i, j) uses centers i + 0.5 and j + 0.5 divided by
scale. seed selects a deterministic realization; None selects
one from local entropy. evolution is a continuous third-coordinate
phase shared by every octave. Absolute octave values are weighted by
gain, with frequencies set by lacunarity, then normalized to
[0, 1] with C = sqrt(3) / 2.
Each octave uses the ordinary xy coordinate while both axes remain finite
and below 2**53, the largest double value with unit lattice precision.
If frequency growth or division by scale makes an axis non-finite or
reaches that limit, that axis evaluates at lattice origin 0.0 for the
octave. The seed-derived octave stream and finite evolution phase stay
active, giving a deterministic finite limit that may be constant along one
or both image axes.
The returned fp32 Frame reports the requested colorspace and gamma,
declares channels ("Y",), and owns a new C-contiguous allocation.
checkerboard(*, width, height, cell, colors, offset=(0.0, 0.0), colorspace, gamma='linear', aa='distance')
Generate a periodic two-color checkerboard in continuous coordinates.
The first color occupies the origin cell. Coordinates are (x, y) and
pixel (i, j) is sampled at (i + 0.5, j + 0.5) with distance,
fixed 4x4 supersample, or binary-off AA. Mixing occurs in the declared
gamma space without scene-value clamp. Metadata uses the requested
colorspace, gamma, and color-derived channels; output owns a new allocation.
color_bars(*, width, height, standard, output='normalized')
Generate one standards-bound RGB color-bar Frame.
standard determines integer-aligned region geometry, colorspace,
gamma, and RGB channels. normalized returns fp32 full-range values:
narrow standards use (code - 64) / 876 and PQ full range uses
code / 1023. code returns the exact 10-bit values in a uint16
Frame; scale management remains the caller's responsibility. Bars have no
edge AA, scene sub-black remains negative after normalization, and every
call returns a new C-contiguous allocation.
grid(*, width, height, cell, line_width, color, background, offset=(0.0, 0.0), colorspace, gamma='linear', aa='distance')
Generate a periodic grid in continuous pixel coordinates.
Coordinates are (x, y) with pixel centers at (i + 0.5, j + 0.5).
Lines are centered on the offset lattice, and crossing coverage is united
before one color mix. AA is distance, fixed 4x4 supersample, or binary off.
Scene values are not clamped. Metadata uses the requested colorspace,
gamma, and color-derived channels; output owns a new C-contiguous allocation.
ramp(*, width, height, kind='linear', start, end, start_color, end_color, colorspace, gamma='linear')
Generate a two-color ramp in continuous pixel coordinates.
Coordinates are (x, y) and pixel (i, j) is evaluated at
(i + 0.5, j + 0.5). Linear projection or radial distance saturates to
the endpoint colors, then mixes fp32 values directly in the declared gamma
space. Scene values are not clamped. The returned Frame has colorspace and
gamma from this call, channels derived from color length, and a new
C-contiguous allocation.