core.d.ts

30.2 kB · typescript · 621 lines

1export { default, initSync } from "./pkg/core/mrlyjs_core.js";23/** An rgba color as four bytes. */4export type Color = [number, number, number, number];5/** A tensor: its shape and its flat data as a typed array of its dtype. */6export interface Tensor {7    shape: number[];8    data: Uint8Array | Uint16Array | Uint32Array | Int32Array;9}10/** A cell: the shape, the type bytes, and the flat rgba colors and the tags when present. */11export interface Cell {12    shape: number[];13    types: Uint8Array | Uint16Array | Uint32Array | Int32Array;14    colors?: Uint8Array;15    tags?: Uint8Array | Uint16Array | Uint32Array | Int32Array;16}17/** A hex cell: a flat cell with its projection, orientation and start row. */18export interface Cell6d {19    cell: Cell;20    projection: "Iso" | "Pro" | "Cut";21    orientation: "Horizontal" | "Vertical";22    start: number;23}24/** A color inside plain data, serde's form. */25export interface ColorData {26    r: number;27    g: number;28    b: number;29    a: number;30}31/** A tensor inside plain data, serde's form. */32export interface TensorData {33    shape: number[];34    data: { U8: number[] } | { U16: number[] } | { U32: number[] } | { I32: number[] };35}36/** A cell inside plain data, serde's form. */37export interface CellData {38    types: TensorData;39    colors?: number[][];40    tags?: TensorData;41}42/** A hex cell inside plain data, serde's form. */43export interface Cell6dData {44    cell: { cell: CellData };45    projection: "Iso" | "Pro" | "Cut";46    orientation: "Horizontal" | "Vertical";47    start: number;48}49/** A seeded random stream, opened from a number or a bigint seed. */50export class Rng {51    constructor(seed: number | bigint | string);52    free(): void;53    /** Draws a float at or above zero and below one. */54    unit(): number;55    /** Draws an integer below n, or zero when n is zero. */56    below(n: number): number;57    /** Draws an integer between lo and hi inclusive, or lo when hi is not above lo. */58    range(lo: number, hi: number): number;59    /** Draws a fair coin flip. */60    boolean(): boolean;61    /** Returns true with probability p. */62    chance(p: number): boolean;63    /** Draws amount distinct indices below length, or every index when amount is larger. */64    sample_indices(length: number, amount: number): Uint32Array;65    /** Draws one item of the array, the same draw as Rust's choice. */66    choice<T>(items: ArrayLike<T>): T;67    /** Shuffles the array in place, the same permutation as Rust's shuffle. */68    shuffle<T>(items: T[]): void;69}70/** Squashes rgba pixels to the hex aspect, returning the new width, height and pixels. */71export function hex_fit(pixels: ArrayLike<number>[], width: number, height: number, vertical: boolean, filter: Filter): [number, number, Uint8Array[]];72/** Returns the size a hex rendering wears, the named axis squashed by the triangle ratio. */73export function hex_size(width: number, height: number, vertical: boolean): [number, number];74/** Resamples rgba pixels to a new size. */75export function resample(pixels: ArrayLike<number>[], width: number, height: number, out_w: number, out_h: number, filter: Filter): Uint8Array[];76/** Decodes a png to its width, height, and rgba colors. */77export function unpng(bytes: ArrayLike<number>): [number, number, Uint8Array[]];78/** The height of an equilateral triangle over its side, the squash a hex rendering wears. */79export function HEX_RATIO(): number;80/** The eight bytes every png file starts with. */81export function PNG_MAGIC(): Uint8Array;82/** A rule that turns counter values into colors. */83export type Colorizer = { Bins: { background: ColorData; ramp: ColorData[] } };84export const Colorizer: {85    /** Returns the default Colorizer. */86    default(): Colorizer;87    /** Builds the blue-to-red diverging ramp around a white middle. */88    diverge(): Colorizer;89    /** Builds the black-through-ember fire ramp: black, dark red, orange, light yellow. */90    fire(): Colorizer;91    /** Builds a binned colorizer from a gradient through the given stops. */92    gradient_bins(background: Color, colors: Color[], shades: number): Colorizer;93    /** Builds the white-to-black heat ramp. */94    heat(): Colorizer;95};96/** The element widths a tensor can hold. */97export type Dtype = "U8" | "U16" | "U32" | "I32";98export const Dtype: {99    /** Returns the largest value the width can hold. */100    max(dtype: Dtype): bigint;101};102/** The way a resampling weighs the source pixels it reads. */103export type Filter = "Nearest" | "Linear" | "Box";104export interface ImageData {105    /** The width in pixels. */106    width: number;107    /** The height in pixels. */108    height: number;109    /** The palette index of every pixel, row by row. */110    rows: number[][];111    /** The colors the rows index. */112    palette: ColorData[];113}114/** A paletted image: rows of palette indices and the palette they point into, hex strings in json. */115export class Image {116    /** Builds an image from its four parts. */117    constructor(width: number, height: number, rows: ArrayLike<number>[], palette: Color[]);118    free(): void;119    /** Reads the Image from its plain data. */120    static from(data: ImageData): Image;121    /** Writes the Image as plain data. */122    toJSON(): ImageData;123    /** The width in pixels. */124    get width(): number;125    set width(value: number);126    /** The height in pixels. */127    get height(): number;128    set height(value: number);129    /** The palette index of every pixel, row by row. */130    get rows(): Uint32Array[];131    set rows(value: ArrayLike<number>[]);132    /** The colors the rows index. */133    get palette(): Color[];134    set palette(value: Color[]);135    /** Returns the flat rgba pixels, transparent wherever an index misses the palette. */136    colors(): Uint8Array[];137    /** Builds a paletted image from raw rgba pixels, growing the palette as new colors appear. */138    static from_pixels(width: number, height: number, pixels: ArrayLike<number>[]): Image;139    /** Encodes the image as a png at the given scale. */140    png(scale: number): Uint8Array;141    /** Resamples the image to a new size, its palette rebuilt from the blended pixels. */142    resample(width: number, height: number, filter: Filter): Image;143}144/** The ways paint picks a color within a type's palette. */145export type Mode = "Type" | "Tag" | "Index" | "Enumerate" | "Random" | "Row" | "Column" | "Depth";146export declare namespace cell {147    /** Flips every type to one minus itself, same as invert. */148    export function anti(cell: Cell): Cell;149    /** Maps every type to one at or above the threshold and zero below, dropping colors. */150    export function binarize(cell: Cell, threshold: number): Cell;151    /** Binarizes the types at Otsu's threshold, dropping colors. */152    export function binarize_otsu(cell: Cell): Cell;153    /** Replaces every type with the rounded mean of its masked neighborhood, dropping colors. */154    export function blur(cell: Cell, mask: Tensor, wrap: boolean): Cell;155    /** Returns the painted color at a flat index, or transparent while unpainted or past the end. */156    export function color_at(cell: Cell, flat: number): Uint8Array;157    /** Builds the Kronecker product of the two cells' types. */158    export function combine(cell: Cell, other: Cell): Cell;159    /** Grows the types to the level-fold Kronecker power of themselves, dropping colors and tags. */160    export function fractal(cell: Cell, level: number): Cell;161    /** Flips every type to one minus itself. */162    export function invert(cell: Cell): Cell;163    /** Tags every cell with its concentric shell distance from the center. */164    export function layers(cell: Cell, dtype: Dtype): Cell;165    /** Folds at least two cells into one by chained Kronecker products. */166    export function magic(cells: Cell[]): Cell;167    /** Returns the default mapping of the first six types to white, black, alpha, red, green, and blue. */168    export function mapping(): Record<string, Color[]>;169    /** Stitches same-shaped cells into one grid of reps blocks per axis. */170    export function merge(cells: Cell[], reps: ArrayLike<number>): Cell;171    /** Builds the 3-wide Moore mask of the dimension, every site on but the center. */172    export function moore(dimension: number): Tensor;173    /** Lays the cell each mask entry indexes into that entry's place and merges the lot. */174    export function mosaic(mask: Tensor, cells: Cell[]): Cell;175    /** Tags every cell with its count of target-valued neighbors under the mask. */176    export function neighbors(cell: Cell, mask: Tensor, target: number, wrap: boolean, dtype: Dtype): Cell;177    /** Wraps a tensor of types in a bare cell, colorless and tagless. */178    export function new_(types: Tensor): Cell;179    /** Wraps the cell in count layers of value on every side, dropping colors. */180    export function pad(cell: Cell, count: number, value: number): Cell;181    /** Colors every mapped cell, picking within each type's palette by the mode. */182    export function paint(cell: Cell, mapping: Record<string, Color[]>, mode: Mode, rng?: Rng): Cell;183    /** Stamps value wherever the tiled mask is on, dropping colors. */184    export function perforate(cell: Cell, mask: Tensor, value: number): Cell;185    /** Rebuilds a cell's types, colors and tags at the new shape from one destination-to-source index map. */186    export function remap(cell: Cell, map: ArrayLike<number>, shape: ArrayLike<number>): Cell;187    /** Returns the flat rgba bytes of the cells, four to a cell, the stored color where there is one and opaque black everywhere else. */188    export function rgba(cell: Cell): Uint8Array;189    /** Builds the flat source index of every destination cell after k quarter turns in the plane of the axes. */190    export function rot90_map(shape: ArrayLike<number>, k: number, axes: [number, number]): Uint32Array;191    /** Rotates the cell k quarter turns in the plane of the given axes, carrying colors and tags along. */192    export function rotate(cell: Cell, k: number, axes: [number, number]): Cell;193    /** Returns the shape of the type tensor. */194    export function shape(cell: Cell): Uint32Array;195    /** Returns the number of cells. */196    export function size(cell: Cell): number;197    /** Repeats the cell reps times along each axis, carrying colors and tags along. */198    export function tile(cell: Cell, reps: ArrayLike<number>): Cell;199    /** Builds the flat source index of every destination cell after tiling reps copies per axis. */200    export function tile_map(shape: ArrayLike<number>, reps: ArrayLike<number>): Uint32Array;201}202export declare namespace codec {203    /** Encodes indexed frames as an animated gif89a, each source pixel a scale by scale block. */204    export function gif(frames: ArrayLike<number>[], palette: ArrayLike<number>[], width: number, height: number, scale: number, delay: number): Uint8Array;205    /** Encodes rgba colors as a png, drawing each source pixel as a scale by scale block. */206    export function png(colors: ArrayLike<number>[], width: number, height: number, scale: number): Uint8Array;207}208export declare namespace colors {209    /** Returns the color with its alpha set to level. */210    export function alpha(color: Color, level: number): Color;211    /** Returns the ground rgba of the dark or the light theme. */212    export function board(dark: boolean): Uint8Array;213    /** Formats the color as a css rgb or rgba call. */214    export function css(color: Color): string;215    /** Parses a #RRGGBB or #RRGGBBAA code, hash optional. */216    export function from_hex(hex: string): Color;217    /** Builds a gradient of steps colors sweeping evenly through the given stops. */218    export function gradient(colors: Color[], steps: number): Color[];219    /** Returns the foreground rgba of the dark or the light theme. */220    export function ink(dark: boolean): Uint8Array;221    /** Returns the color with every channel flipped and the alpha kept. */222    export function invert(color: Color): Color;223    /** Returns the color scaled toward black below level 50 and toward white above. */224    export function lightness(color: Color, level: number): Color;225    /** Reads rgba pixels as a type grid, one wherever the rgb mean falls below the level. */226    export function luma_types(pixels: ArrayLike<number>[], width: number, height: number, level: number): Tensor;227    /** Blends two colors linearly by ratio. */228    export function mix(color_1: Color, color_2: Color, ratio: number): Color;229    /** Returns the palette color a name spells. */230    export function named(name: string): Color;231    /** Draws a color from the stream, opaque unless alpha is asked for. */232    export function random(alpha: boolean, rng: Rng): Color;233    /** Builds an opaque color. */234    export function rgb(r: number, g: number, b: number): Color;235    /** Builds a color with an explicit alpha. */236    export function rgba(r: number, g: number, b: number, a: number): Color;237    /** Returns a hue one shade lighter, itself, and one shade darker. */238    export function shades(hue: Color): Color[];239    /** Snaps every pixel to the palette color nearest it in squared rgba distance, first on a tie. */240    export function snap(pixels: ArrayLike<number>[], palette: Color[]): Uint8Array[];241    /** Formats the color as lowercase hex, appending the alpha pair only when not opaque. */242    export function to_hex(color: Color): string;243    /** The fully transparent color. */244    export function ALPHA(): Color;245    /** The palette black, #000000. */246    export function BLACK(): Color;247    /** The palette blue, #008cff. */248    export function BLUE(): Color;249    /** The palette brown, #b18462. */250    export function BROWN(): Color;251    /** The palette cyan, #1ec9f3. */252    export function CYAN(): Color;253    /** The dark theme. */254    export function DARK(): colors.Theme;255    /** The palette gray, #8e8e93. */256    export function GRAY(): Color;257    /** The palette green, #32cc58. */258    export function GREEN(): Color;259    /** The palette indigo, #6768fa. */260    export function INDIGO(): Color;261    /** The light theme. */262    export function LIGHT(): colors.Theme;263    /** The palette mint, #00d1bb. */264    export function MINT(): Color;265    /** The fifteen names, in palette order. */266    export function NAMES(): string[];267    /** The palette orange, #ff8f2c. */268    export function ORANGE(): Color;269    /** The fifteen colors, in name order. */270    export function PALETTE(): Color[];271    /** The palette pink, #ff325a. */272    export function PINK(): Color;273    /** The palette purple, #d332e9. */274    export function PURPLE(): Color;275    /** The palette red, #ff3d40. */276    export function RED(): Color;277    /** The palette teal, #00cad8. */278    export function TEAL(): Color;279    /** The palette white, #ffffff. */280    export function WHITE(): Color;281    /** The palette yellow, #ffd100. */282    export function YELLOW(): Color;283    export interface ThemeData {284        /** The ground every figure is painted on. */285        ground: ColorData;286        /** The page background, one step off the ground. */287        bg: ColorData;288        /** The raised panel. */289        panel: ColorData;290        /** The sunken well. */291        deep: ColorData;292        /** The hairline between things. */293        line: ColorData;294        /** The foreground, the strongest tone. */295        fg: ColorData;296        /** The dimmed foreground, for anything secondary. */297        dim: ColorData;298        /** The interactive accent. */299        accent: ColorData;300        /** The tone written on the accent. */301        on_accent: ColorData;302        /** The red ink. */303        red: ColorData;304        /** The orange ink. */305        orange: ColorData;306        /** The yellow ink. */307        yellow: ColorData;308        /** The green ink. */309        green: ColorData;310        /** The mint ink. */311        mint: ColorData;312        /** The teal ink. */313        teal: ColorData;314        /** The cyan ink. */315        cyan: ColorData;316        /** The blue ink. */317        blue: ColorData;318        /** The indigo ink. */319        indigo: ColorData;320        /** The purple ink. */321        purple: ColorData;322        /** The pink ink. */323        pink: ColorData;324        /** The brown ink. */325        brown: ColorData;326        /** The gray ink. */327        gray: ColorData;328    }329    /** One theme: the surfaces of a dark or a light ground and the thirteen inks, the same on both. */330    export class Theme {331        private constructor();332        free(): void;333        /** Reads the Theme from its plain data. */334        static from(data: ThemeData): Theme;335        /** Writes the Theme as plain data. */336        toJSON(): ThemeData;337        /** The ground every figure is painted on. */338        get ground(): Color;339        set ground(value: Color);340        /** The page background, one step off the ground. */341        get bg(): Color;342        set bg(value: Color);343        /** The raised panel. */344        get panel(): Color;345        set panel(value: Color);346        /** The sunken well. */347        get deep(): Color;348        set deep(value: Color);349        /** The hairline between things. */350        get line(): Color;351        set line(value: Color);352        /** The foreground, the strongest tone. */353        get fg(): Color;354        set fg(value: Color);355        /** The dimmed foreground, for anything secondary. */356        get dim(): Color;357        set dim(value: Color);358        /** The interactive accent. */359        get accent(): Color;360        set accent(value: Color);361        /** The tone written on the accent. */362        get on_accent(): Color;363        set on_accent(value: Color);364        /** The red ink. */365        get red(): Color;366        set red(value: Color);367        /** The orange ink. */368        get orange(): Color;369        set orange(value: Color);370        /** The yellow ink. */371        get yellow(): Color;372        set yellow(value: Color);373        /** The green ink. */374        get green(): Color;375        set green(value: Color);376        /** The mint ink. */377        get mint(): Color;378        set mint(value: Color);379        /** The teal ink. */380        get teal(): Color;381        set teal(value: Color);382        /** The cyan ink. */383        get cyan(): Color;384        set cyan(value: Color);385        /** The blue ink. */386        get blue(): Color;387        set blue(value: Color);388        /** The indigo ink. */389        get indigo(): Color;390        set indigo(value: Color);391        /** The purple ink. */392        get purple(): Color;393        set purple(value: Color);394        /** The pink ink. */395        get pink(): Color;396        set pink(value: Color);397        /** The brown ink. */398        get brown(): Color;399        set brown(value: Color);400        /** The gray ink. */401        get gray(): Color;402        set gray(value: Color);403        /** The thirteen inks in name order. */404        hues(): Color[];405        /** The six inks a figure cycles through: blue, orange, yellow, green, pink, indigo. */406        inks(): Color[];407    }408}409export declare namespace error {410    /** Parses JSON text into a value. */411    export function parse(text: string): any;412}413export declare namespace image {414    /** Box-blurs rgba pixels by radius, each channel the mean of its edge-padded window. */415    export function blur(pixels: ArrayLike<number>[], width: number, height: number, radius: number): Uint8Array[];416}417export declare namespace paint {418    /** Colors the cell from the paint's inks under its edition mode, scattering the Random edition from the stream. */419    export function apply(paint: paint.Paint, cell: Cell, rng: Rng): void;420    /** Replays a stored paint onto a cell, tagging first and applying it from the stream. */421    export function coat(cell: Cell, paint: paint.Paint, mask: Tensor | undefined, rng: Rng): void;422    /** Draws a random paint under the config, applies it to the cell, and returns the recipe. */423    export function paint(cell: Cell, config: paint.Config, mask: Tensor | undefined, rng: Rng): paint.Paint;424    /** Tags the cell for Layers and Neighbors paints and sizes the palette to the tag count. */425    export function prime(paint: paint.Paint, cell: Cell, mask: Tensor | undefined, rng: Rng): paint.Paint;426    /** Draws a random edition from the allowed list, or from all seven. */427    export function random_edition(editions: paint.Edition[] | undefined, rng: Rng): paint.Edition;428    /** Redraws the paint's secondary inks and shades under its scheme. */429    export function reroll(paint: paint.Paint, rng: Rng): paint.Paint;430    /** Draws the paint's scheme, target and primary under the config, then rerolls the rest. */431    export function setup(paint: paint.Paint, config: paint.Config, rng: Rng): paint.Paint;432    /** Tags the cell for the Layers and Neighbors editions and returns the distinct tag count on the secondary side. */433    export function tag(cell: Cell, edition: paint.Edition, target: paint.Target, mask?: Tensor): number;434    /** The constraints a caller may put on a random paint. */435    export interface Config {436        /** The editions allowed, or None for all seven. */437        editions?: paint.Edition[];438        /** The primary inks allowed, or None for black and white. */439        primaries?: paint.Ink[];440        /** The forced target, or None for a coin flip. */441        target?: paint.Target;442    }443    export const Config: {444        /** Returns the default Config. */445        default(): paint.Config;446    };447    /** The seven ways a paint distributes its colors over a cell. */448    export type Edition = "Simple" | "Index" | "Layers" | "Neighbors" | "Rows" | "Columns" | "Random";449    export const Edition: {450        /** Returns every Edition in canonical order. */451        all(): paint.Edition[];452        /** Returns the cell-painting mode this edition renders with, or None for Random, which scatters. */453        mode(edition: paint.Edition): Mode | undefined;454    };455    /** The fifteen named inks a paint draws from. */456    export type Ink = "Black" | "White" | "Red" | "Orange" | "Yellow" | "Green" | "Mint" | "Teal" | "Cyan" | "Blue" | "Indigo" | "Purple" | "Pink" | "Brown" | "Gray";457    export const Ink: {458        /** Returns every Ink in canonical order. */459        all(): paint.Ink[];460        /** Returns the ink's color. */461        color(ink: paint.Ink): Color;462    };463    export interface PaintData {464        /** The coloring edition. */465        edition: paint.Edition;466        /** The secondary color scheme. */467        scheme: paint.Scheme;468        /** The side the primary ink lands on. */469        target: paint.Target;470        /** The primary ink. */471        primary: paint.Ink;472        /** The secondary inks. */473        secondary: paint.Ink[];474        /** The shade indices of a multitone ramp. */475        shades: number[];476    }477    /** A complete coloring recipe for one cell. */478    export class Paint {479        /** Builds a black-primary, fill-target, multicolor paint for an edition. */480        constructor(edition: paint.Edition);481        free(): void;482        /** Reads the Paint from its plain data. */483        static from(data: PaintData): Paint;484        /** Writes the Paint as plain data. */485        toJSON(): PaintData;486        /** The coloring edition. */487        get edition(): paint.Edition;488        set edition(value: paint.Edition);489        /** The secondary color scheme. */490        get scheme(): paint.Scheme;491        set scheme(value: paint.Scheme);492        /** The side the primary ink lands on. */493        get target(): paint.Target;494        set target(value: paint.Target);495        /** The primary ink. */496        get primary(): paint.Ink;497        set primary(value: paint.Ink);498        /** The secondary inks. */499        get secondary(): paint.Ink[];500        set secondary(value: paint.Ink[]);501        /** The shade indices of a multitone ramp. */502        get shades(): Uint32Array;503        set shades(value: ArrayLike<number>);504        /** Returns true for the Simple edition. */505        is_simple(): boolean;506    }507    /** The two ways secondary colors are drawn. */508    export type Scheme = "Multicolor" | "Multitone";509    export const Scheme: {510        /** Returns every Scheme in canonical order. */511        all(): paint.Scheme[];512    };513    /** The side of the figure the primary ink lands on. */514    export type Target = "Fill" | "Void";515    export const Target: {516        /** Returns every Target in canonical order. */517        all(): paint.Target[];518    };519}520export declare namespace ramp {521    /** Returns the color for one value against the range maximum: the background at zero, the top of the ramp from the maximum up. */522    export function color(colorizer: Colorizer, value: number, max: number): Color;523    /** Maps a slice of values to rgba pixels against the range maximum. */524    export function colors(colorizer: Colorizer, values: ArrayLike<number>, max: number): Uint8Array[];525}526export declare namespace rng {527    /** Draws an integer below n, or zero when n is zero. */528    export function below(rng: Rng, n: number): number;529    /** Draws a fair coin flip. */530    export function boolean(rng: Rng): boolean;531    /** Returns true with probability p. */532    export function chance(rng: Rng, p: number): boolean;533    /** Builds the stream from a seed. */534    export function new_(seed: number | bigint): Rng;535    /** Draws an integer between lo and hi inclusive, or lo when hi is not above lo. */536    export function range(rng: Rng, lo: number | bigint, hi: number | bigint): bigint;537    /** Draws amount distinct indices below length, or every index when amount is larger. */538    export function sample_indices(rng: Rng, length: number, amount: number): Uint32Array;539    /** Draws a float at or above zero and below one. */540    export function unit(rng: Rng): number;541}542export declare namespace tensor {543    /** Returns the element at a flat index, which must be below the size like a slice index. */544    export function at(tensor: Tensor, flat: number): bigint;545    /** Maps every element to one at or above the threshold, zero below. */546    export function binarize(tensor: Tensor, threshold: number): Tensor;547    /** Binarizes at one above the Otsu threshold. */548    export function binarize_otsu(tensor: Tensor): Tensor;549    /** Averages every position over its masked neighborhood, rounded. */550    export function blur(tensor: Tensor, mask: Tensor, wrap: boolean): Tensor;551    /** Returns the elements as bytes. */552    export function bytes(tensor: Tensor): Uint8Array;553    /** Counts the cells holding one value. */554    export function count(tensor: Tensor, value: number): number;555    /** Returns the element width. */556    export function dtype(tensor: Tensor): Dtype;557    /** Counts the faces where filled cells meet empty cells or the boundary: perimeter in 2d, surface in 3d. */558    export function exposed(tensor: Tensor): string;559    /** Builds a tensor of the shape and width filled with one value. */560    export function filled(shape: ArrayLike<number>, value: number | bigint, dtype: Dtype): Tensor;561    /** Reverses the tensor along one axis. */562    export function flip(tensor: Tensor, axis: number): Tensor;563    /** Folds the tensor into its level-fold Kronecker power. */564    export function fractal(tensor: Tensor, level: number): Tensor;565    /** Builds a u8 tensor filled with one value. */566    export function full(shape: ArrayLike<number>, value: number): Tensor;567    /** Returns the byte at a multi-index. */568    export function get(tensor: Tensor, multi: ArrayLike<number>): number;569    /** Wraps an i32 vector as a tensor of the shape. */570    export function i32(data: ArrayLike<number>, shape: ArrayLike<number>): Tensor;571    /** Returns the elements as i32s. */572    export function i32s(tensor: Tensor): Int32Array;573    /** Folds a multi-index into its flat index. */574    export function index(tensor: Tensor, multi: ArrayLike<number>): number;575    /** Flips every element between zero and one. */576    export function invert(tensor: Tensor): Tensor;577    /** Builds the Kronecker product of the two tensors. */578    export function kron(tensor: Tensor, other: Tensor): Tensor;579    /** Numbers every position by its concentric ring out from the center. */580    export function layers(tensor: Tensor, dtype: Dtype): Tensor;581    /** Counts each position's masked neighbors holding the target bit. */582    export function neighbors(tensor: Tensor, mask: Tensor, target: number, wrap: boolean, dtype: Dtype): Tensor;583    /** Builds a zeroed u8 tensor of the shape. */584    export function new_(shape: ArrayLike<number>): Tensor;585    /** Wraps a byte vector as a tensor of the shape. */586    export function of(data: ArrayLike<number>, shape: ArrayLike<number>): Tensor;587    /** Returns the Otsu threshold splitting the histogram at greatest variance. */588    export function otsu_threshold(tensor: Tensor): number;589    /** Wraps the tensor in a count-thick border of one value. */590    export function pad(tensor: Tensor, count: number, value: number): Tensor;591    /** Stamps the value wherever the tiled mask is nonzero. */592    export function perforate(tensor: Tensor, mask: Tensor, value: number): Tensor;593    /** Writes the element at a flat index, which must be below the size like a slice index. */594    export function put(tensor: Tensor, flat: number, value: number | bigint): void;595    /** Rotates the tensor k quarter turns in the plane of two axes. */596    export function rot90(tensor: Tensor, k: number, axes: [number, number]): Tensor;597    /** Writes the byte at a multi-index. */598    export function set(tensor: Tensor, multi: ArrayLike<number>, value: number): void;599    /** Returns the number of elements. */600    export function size(tensor: Tensor): number;601    /** Drops one axis by fixing it at an index. */602    export function slice(tensor: Tensor, axis: number, index: number): Tensor;603    /** Returns the sum of all elements. */604    export function sum(tensor: Tensor): bigint;605    /** Repeats the tensor the given number of times along each axis. */606    export function tile(tensor: Tensor, reps: ArrayLike<number>): Tensor;607    /** Swaps two axes. */608    export function transpose(tensor: Tensor, a: number, b: number): Tensor;609    /** Builds a zeroed tensor of the shape and width. */610    export function typed(shape: ArrayLike<number>, dtype: Dtype): Tensor;611    /** Wraps a u16 vector as a tensor of the shape. */612    export function u16(data: ArrayLike<number>, shape: ArrayLike<number>): Tensor;613    /** Returns the elements as u16s. */614    export function u16s(tensor: Tensor): Uint16Array;615    /** Wraps a u32 vector as a tensor of the shape. */616    export function u32(data: ArrayLike<number>, shape: ArrayLike<number>): Tensor;617    /** Returns the elements as u32s. */618    export function u32s(tensor: Tensor): Uint32Array;619    /** Wraps a u8 vector as a tensor of the shape, the same door as [`Tensor::of`]. */620    export function u8(data: ArrayLike<number>, shape: ArrayLike<number>): Tensor;621}