import { Expr, GpuFragmentParams } from '../gpu/contract'; import { PropRef } from './values'; /** * The canvas a generator paints on: its `uv`, its `viewport` size in pixels and its `aspect`. * * `uv` runs 0–1 across the layer, y down. `aspect` is width over height. When a parent fits * the layer into a box, `viewport` and `aspect` describe that box. Every frame takes this as * its second argument. * * @example * ```ts * paint: (params) => { const {uv, viewport, aspect} = surfaceOf(params); … } * ``` * @see rawSurfaceOf, centredFrame, segmentFrame */ export declare function surfaceOf(params: GpuFragmentParams): { uv: Expr; viewport: Expr; aspect: Expr; }; /** * The canvas like `surfaceOf`, but always measured against the whole canvas, never a fitted box. * * Use it when a pattern should stay anchored to the canvas as the layer is resized. * * @example * ```ts * const {delta, dist} = centredFrame({center: p('center')})(params, rawSurfaceOf(params)) * ``` * @see surfaceOf */ export declare function rawSurfaceOf(params: GpuFragmentParams): { uv: Expr; viewport: Expr; aspect: Expr; }; /** What `centredFrame` gives you for each pixel. */ export interface CentredFrame { /** The vector from the centre to the pixel, aspect-corrected (in canvas-height units). */ delta: Expr; /** The distance from the centre, in canvas-height units. */ dist: Expr; } /** * A frame centred on a position prop: each pixel's offset from the centre and its distance. * * Pass `{center: p('center')}` where `center` is a position prop. Call the result with * `params` and a surface. Distances are aspect-corrected, so 1 is the canvas height and a * circle stays round on a wide canvas. * * @example * ```ts * const {dist} = centredFrame({center: p('center')})(params, surfaceOf(params)) * ``` * @tip `dist` is in canvas-height units: a radius of 0.5 reaches the top and bottom edges from the middle. * @see segmentFrame, surfaceOf, rawSurfaceOf */ export declare function centredFrame(slots: { center: PropRef; }): (params: GpuFragmentParams, surface: { uv: Expr; aspect: Expr; }) => CentredFrame; /** What `segmentFrame` gives you for each pixel. */ export interface SegmentFrame { /** How far the pixel is along the line from `from` toward `to` (0 at `from`), in canvas-height units. */ along: Expr; /** The signed distance from the line: positive below a left-to-right line, negative above. */ across: Expr; /** The length of the line from `from` to `to`, in canvas-height units (never less than 0.0001). */ length: Expr; } /** * A frame along the line between two position props: how far each pixel is along it and across it. * * Pass `{from: p('from'), to: p('to')}` and call the result with `params` and a surface. * `along` is 0 at `from` and equals `length` at `to`. `across` is the signed distance from the * line. All three are aspect-corrected, in canvas-height units. * * @example * ```ts * const {along, across, length} = segmentFrame({from: p('from'), to: p('to')})(params, surfaceOf(params)) * ``` * @tip Divide `along` by `length` for a 0–1 position along the line, the natural gradient parameter. * @see centredFrame, directionFrame, surfaceOf */ export declare function segmentFrame(slots: { from: PropRef; to: PropRef; }): (params: GpuFragmentParams, surface: { uv: Expr; aspect: Expr; }) => SegmentFrame; /** * A direction in degrees as a unit vector. * * 0° points right and angles turn clockwise on screen, so 90° points down. Use it wherever a * word wants a light or flow direction as a vector. * * @example * ```ts * const light = direction(params.uniforms.lightAngle, 'light') * ``` * @see directionFrame */ export declare function direction(angleDeg: Expr | number, hint?: string): Expr; /** What `directionFrame` gives you. */ export interface DirectionFrame { /** The unit vector pointing along the direction. */ tangent: Expr; /** The unit vector at right angles to it. */ perp: Expr; /** Project a 2D point into the frame: its distance `along` the direction and `across` it. */ coordsOf(p: Expr): { along: Expr; across: Expr; }; } /** * The two axes of a direction given in degrees, for patterns that run along it. * * `tangent` points along the direction, `perp` at right angles to it. `coordsOf(point)` * returns that point's `along` and `across` distances in the frame. Brush grain, weave, * streaks and flow all live in one of these. * * @example * ```ts * const grain = directionFrame(params.uniforms.brushAngle, 'brush'); const {along, across} = grain.coordsOf(delta) * ``` * @see direction, segmentFrame */ export declare function directionFrame(angleDeg: Expr | number, hint?: string): DirectionFrame; /** * Fold a point into one mirrored wedge around a centre: the kaleidoscope fold. * * `sectorAngle` is the wedge's angle in radians (2π divided by the number of facets). `center` * is where the wedges meet, 0.5 by default. Returns the folded point as an offset from the * centre. Sample anything at that point and it repeats and mirrors around the centre. * * @example * ```ts * const folded = sectorFold(uv.member('x'), uv.member('y'), math.div(2 * Math.PI, params.uniforms.facets)) * ``` * @see directionFrame, centredFrame */ export declare function sectorFold(x: Expr, y: Expr, sectorAngle: Expr, center?: number): Expr; //# sourceMappingURL=frames.d.ts.map