/** * Builds one shader from the effects that were chosen. * * An effect is an object of GLSL function bodies, each optional: * * vertex vec3 ( vec3 p, vec2 uv ) moves the mesh. `p` is in * px from the centre of the * quad, z towards the viewer * uv vec2 ( vec2 uv ) moves the lookup * color vec4 ( vec4 color, vec2 uv ) changes the result; may * call `media( uv )` * and, over the whole canvas, after all slides are drawn (see `pass.js`), * * post vec4 ( vec4 color, vec2 uv ) may call `scene( uv )` * * and, for a stack, * * transition GLSL with a function `vec4 transition( vec2 uv )` that * mixes `getFromColor( uv )` and `getToColor( uv )` by * `progress`, 0 to 1. `resolution` and `time` are there * too: what is written for gl-transitions runs as it is * * and * * params numbers, or arrays of 1 to 4, that the bodies use by * their name. An array can be written into while the * effect runs: the next frame is drawn with what it has * head GLSL the bodies need: helper functions * animated true when it moves without the slider moving; 'pointer' * when it does so while the pointer is over the slider * place what `vertex` does, in JS: `( p, about, uv )` with `p` * as `[ x, y, z ]`, which it changes or gives back * another, and `about` with `progress`, `velocity`, * `size`, `view` and `quad` as the uniforms of their * names. For effects that lay the slides out: a click * finds the slide that is seen (see `hit.js`) * * `uv` runs over the quad from the top left, 0 to 1. The quad is the media * of a slide, or the whole view in a stack. * * What every body can read: * * uProgress where the slide is, in slides from its resting place * uVelocity how fast the slider moves to the right on the screen, in * views per second, smoothed * uPointer the pointer in the quad's uv, smoothed * uPointerSpeed how fast it moves, in sizes of the quad per second, * smoothed * uPointerIn 1 while the pointer is over the slider, eased * uTime seconds * uSize size of the quad, px * uView size of the view, px * uQuad the quad in the view, px: left, top, width, height * uRadius how round the corners of the quad are, px; not in * `vertex` * uShape the exponent of the corners: 2 round, 4 a squircle; * not in `vertex` * * What the effects do is weighed by uFx, 1 but for a quad whose effects * fade (see `change` of the layer). * * Effects are chained in the order given. * * Effects are written for slides that follow each other to the side. In a * slider that goes down they get everything turned by a quarter: `uv`, `p` * and the uniforms have the way of the slides as their x. So `stretch` * bows along the way, whatever the way is. */ /** What `place` of an effect gets: the uniforms of these names. */ export interface About { progress: number; velocity: number; size: number[]; view: number[]; quad: number[]; } export interface Effect { /** * Numbers, or arrays of 1 to 4, that the bodies use by their name. What * is written into an array is drawn in the next frame. */ params?: Record; /** Moves the mesh. */ vertex?: string; /** Moves the lookup. */ uv?: string; /** Changes the result. */ color?: string; /** For a stack: mixes two slides. */ transition?: string; /** * Changes what all slides drew, over the whole canvas: crosses the * gaps and the borders of the slides (see `pass.js`). */ post?: string; /** * Whether its transition is drawn in a row too, as `edges()` does; any * other is for a stack, and a row leaves it out. */ row?: boolean; /** GLSL the bodies need: helper functions. */ head?: string | string[]; /** What `vertex` does, in JS: where a point of the mesh is drawn. */ place?: (p: number[], about: About, uv: number[]) => number[] | void; /** * Moves without the slider moving: always, or while the pointer is over * the slider. */ animated?: boolean | 'pointer'; } /** * @param effects Effects. * @param transition The transition of a stack when no effect * has one; null for a row. * @param y The slides follow each other downwards. * @return `vertex` and `fragment` (sources), `params` (uniform name * to value), `mesh` (whether the quad needs to bend), * `pointer`, `animated`, `hover` (animated while the * pointer is over the slider) and `placed` (whether a * slide at rest looks different from what the page draws). */ export declare function compose(effects: Effect[], transition: string | null, y?: boolean): { vertex: string; fragment: string; params: Record; mesh: boolean; pointer: boolean; animated: boolean; hover: boolean; placed: boolean; }; /** * Hands a program to the compiler. Nothing here waits for it: where the * browser compiles on another thread, the page goes on meanwhile. * * @param gl Context. * @param vertex Source. * @param fragment Source. * @return Program, not yet ready (see `ready()`). */ export declare function build(gl: WebGL2RenderingContext, vertex: string, fragment: string): WebGLProgram; /** * @param gl Context. * @param program Program. * @return Whether the compiler is done with it. * @throws {Error} With the log of the compiler, when it failed. */ export declare function ready(gl: WebGL2RenderingContext, program: WebGLProgram): boolean;