/** Returns a stable pseudo-random number in [0, 1) for a cell and a seed. */ export declare function hash(x: number, y: number, seed?: number): number; export declare function clamp01(value: number): number; export declare function smoothstep(edge0: number, edge1: number, value: number): number; export declare function easeInOutCubic(value: number): number; /** Fades from 1 to 0 over `length` milliseconds once `elapsed` reaches 0, for a short flash. */ export declare function flash(elapsed: number, length: number): number; /** Maps real time to reveal time, easing from the loading band's 2x speed to normal speed. */ export declare class RevealPace { /** Virtual milliseconds that the transition takes at normal speed. */ readonly length: number; /** Omit the prefix without changing the remaining transition's speed curve. */ private readonly startAt; private static readonly steps; /** Real milliseconds at which each step of the transition is reached. */ private readonly realTimes; private readonly skippedDuration; /** Real milliseconds that the whole transition takes. */ readonly duration: number; constructor( /** Virtual milliseconds that the transition takes at normal speed. */ length: number, /** Omit the prefix without changing the remaining transition's speed curve. */ startAt?: number); /** Returns the virtual milliseconds of the transition that have passed after `real` milliseconds. */ virtualAt(real: number): number; } /** * Returns the stage a cell has reached by `time`, given when it reaches each stage after the * first, so a cell whose image has appeared is at stage 0 until `times[0]`. */ export declare function stageAt(time: number, times: ArrayLike): number; /** A comet-like wave sweeping a band from left to right, in CSS pixels. */ export interface ILoadingWave { /** Position of the brightest point. */ readonly head: number; /** Length of the fading tail behind the head. */ readonly tail: number; /** Varies each sweep a little, so that repeated sweeps don't look mechanical. */ readonly seed: number; } /** Virtual milliseconds per sweep of a loading wave at normal speed. */ export declare const wavePeriod = 3200; /** Places a wave whose sweep, from entering on the left to leaving on the right, is `progress` done. */ export declare function placeWave(progress: number, width: number, seed: number, tail?: number): ILoadingWave; /** Returns the loading wave at a virtual time. Every band that shares the clock shows the same wave. */ export declare function getLoadingWave(width: number, time: number): ILoadingWave; /** Brightness of a wave at `x`: a soft leading edge, a bright head and a long fading tail. */ export declare function waveIntensity(wave: ILoadingWave, x: number): number; /** Fine texture that keeps a wave from looking like a flat gradient. */ export declare function waveRipple(wave: ILoadingWave, x: number, y: number, time: number): number; /** How strongly a wave fills a row of a band: fullest along the middle, thinner toward its edges. */ export declare function bandProfile(y: number, height: number): number; /** Opacity of a twinkling background cell at a virtual time, or 0 while it rests. */ export declare function twinkle(column: number, row: number, time: number): number; /** * A loaded image at its displayed size, read once so that every texture stage can be derived from * it: brightness stretched to the image's own range, mean colors of cells of any size, and a small * palette of colors that represent it. */ export declare class ImageSamples { readonly width: number; readonly height: number; /** RGBA of every CSS pixel, row by row. */ readonly pixels: Uint8ClampedArray; /** Brightness of every CSS pixel from 0 to 1, inverted for light themes. */ readonly brightness: Float32Array; private readonly brightnessCells; private readonly colorCells; private readonly paletteCells; private paletteColors; private constructor(); /** Samples an image at a size, or returns undefined when it cannot be read. */ static create(image: HTMLImageElement, width: number, height: number, invert: boolean): ImageSamples | undefined; /** Number of columns in a grid of `size`-pixel cells that starts at the top-left corner. */ columns(size: number): number; /** Mean brightness of each `size`-pixel cell, row by row. */ cells(size: number): Float32Array; /** Mean RGB of each `size`-pixel cell, three values per cell. */ colors(size: number): Float32Array; /** A few colors that represent the image, found by k-means, three values per color. */ get palette(): Float32Array; /** * Index into {@link palette} of each `size`-pixel cell. Each cell is ordered-dithered between its * two nearest palette colors, so flat areas stay flat and blends between them become patterns. */ paletteIndices(size: number): Uint8Array; private average; } /** One painted frame of a texture reveal. */ export interface ITextureFrame { readonly width: number; /** Height of the image's frame, in CSS pixels. */ readonly height: number; /** Opacity of the image itself, which takes over at the end. */ readonly imageOpacity: number; /** Opacity of the texture over the image. */ readonly textureOpacity: number; } export interface ITextureRevealOptions { /** The loaded image, which the last stages show through the texture in its true colors. */ readonly image: HTMLImageElement; readonly samples: ImageSamples; /** Width of the loading indicator that the frame grows or narrows from, in CSS pixels. */ readonly fromWidth: number; /** Height of the loading indicator that the frame grows from, in CSS pixels. */ readonly fromHeight: number; readonly timing: ITextureRevealTiming; /** Real milliseconds the reveal takes. */ readonly duration: number; readonly onFrame: (frame: ITextureFrame) => void; } /** A texture reveal in progress. */ export interface ITextureReveal { readonly options: ITextureRevealOptions; /** A keyframe-less animation whose time is the reveal's clock, so that the reveal can be paused and sought. */ readonly clock: Animation; } /** One timeline for resizing and revealing the image, without waiting for the loading sweep. */ export interface ITextureRevealTiming { /** How the reveal's real time maps to the transition's virtual time. */ readonly pace: RevealPace; /** The virtual time of the last painted loading frame, so that its wave and glyphs continue without a cut. */ readonly loadingTime: number; /** Virtual milliseconds until the last loading wave's wake has left the band. */ readonly loadingEnd: number; }