UNPKG

@thi.ng/rasterize

Version:

Headless 2D shape drawing, filling & rasterization for arbitrary targets/purposes (no canvas required)

53 lines 2.12 kB
import type { IGrid2D, NumericArray, TypedArray } from "@thi.ng/api"; import type { BlendFnF, BlendFnI, ReadonlyColor } from "@thi.ng/porter-duff"; import type { IRandom } from "@thi.ng/random"; import type { Shader2D } from "./api.js"; export declare const defPattern: <T extends any[] | TypedArray, P>(pattern: IGrid2D<T, P>) => Shader2D<P>; export interface StripeShaderOpts<T> { dir: "h" | "v" | "d"; size: number; sizeA: number; a: T; b: T; } export declare const defStripes: <T = number>({ dir, size, sizeA, a, b, }: StripeShaderOpts<T>) => Shader2D<T>; export interface RandomShaderOpts<T> { probability?: number; rnd?: IRandom; a: T; b: T; } export declare const defNoise: <T = number>(opts: RandomShaderOpts<T>) => Shader2D<T>; /** * Defines a shader (for floating point target buffers) which blends given color * (or another shader) with a Porter-Duff operator. Unless `isPremultiplied` is * true, both the given color and existing pixel values in the target buffer are * considered non-premultiplied. * * @remarks * The default PD blend op is `SRC_OVER_I`. See * [@thi.ng/porter-duff](https://thi.ng/porter-duff) for more info. * * See {@link defBlendI} for integer based buffers. * * @param col * @param blend * @param isPremultiplied */ export declare const defBlendF: (col: ReadonlyColor | Shader2D<NumericArray>, blend?: BlendFnF, isPremultiplied?: boolean) => Shader2D<NumericArray>; /** * Similar to {@link defBlendF}, but for integer based target buffers. Defines a * shader which blends given color (or another shader) with a Porter-Duff * operator. Unless `isPremultiplied` is true, both the given color and existing * pixel values in the target buffer are considered non-premultiplied. * * @remarks * The default PD blend op is `SRC_OVER_I`. See * [@thi.ng/porter-duff](https://thi.ng/porter-duff) for more info. * * @param col * @param blend * @param isPremultiplied */ export declare const defBlendI: (col: number | Shader2D<number>, blend?: BlendFnI, isPremultiplied?: boolean) => Shader2D<number>; //# sourceMappingURL=shader.d.ts.map