import { Point } from "./planimetry"; export declare type PureParams = number | string | boolean; export declare type PureFunction = (x: PureParams) => any; export declare type PureNumberFunction = (x: number) => any; export declare type colorChannels = [number[], number[], number[], number[]]; /** * 将输入参数为一个数值的纯函数缓存化,即多次f(x)只要x与上次传入的x相同则直接返回上次的结果,反之更新 * @param fn 需要缓存的数字纯函数 */ export declare const cacheLast: (fn: PureNumberFunction) => (arg: number) => any[]; /** * 返回[0,1,2,3,...,n-1] * @param n 需要循环生成的数组长度 */ export declare const range: (n: number) => number[]; /** * range函数的缓存版本 */ export declare const crange: (arg: number) => any[]; /** * Array.map 的函数式写法 * @param callbackfn map的处理函数 * @param t 需要处理的数组 */ export declare const map: (callbackfn: (value: any, index: number, array: any[]) => any, t: any[]) => any[]; /** * 分离ImageData中的4个通道 * @param imageData 图像数据 */ export declare function colorChannel({ data }: ImageData): colorChannels; /** * 将数值数组1与数值数组2的各个相同下标的数值元素相加,返回长度为数组1长度的结果数组 * @param arr1 数值数组1 * @param arr2 数值数组2 */ export declare function addArray(arr1: number[], arr2: number[]): number[]; /** * 将多个数值数组的值相加 * @param v 多个数值数组 */ export declare function addArrays(...v: number[][]): number[]; /** * 将arr数组的每个元素拷贝times次 * @param times 拷贝次数 * @param arr 原数组 * @example * copyArrayElements(4,[1,2,3]); // [1,1,1,1,2,2,2,2,3,3,3,3] */ export declare function copyArrayElements(times: number, arr: number[]): number[]; /** * 将arr数组分片为指定带下的chunks * @param size 分片的大小 * @param arr 需要分片的数组 * @example * chunk(4,[1]); // [[1]] * chunk(4,[1,2,3,4,5]); // [[1,2,3,4],[5]] * chunk(2,[1,2,3,4,5]); // [[1,2],[3,4],[5]] */ export declare function chunk(size: number, arr: any[]): any[][]; /** * 生成数组滑窗 * @param size 滑窗大小 * @param arr 数组 * @example * sliding(2,[1]); // [[1]] * sliding(2,[1,2]); // [[1,2]] * sliding(2,[1,2,3]); // [[1,2],[2,3]] * sliding(1,[1,2,3]); // [[1],[2],[3]] * sliding(0,[1]); // [[1]] * sliding(0,[1,2,3]); // [[1,2,3]] * sliding(-1,[1,2,3]); // [[1,2,3]] * */ export declare function sliding(size: number, arr: any[]): any[][]; /** * 合并4个图像通道为一个图像数据 * @param channels 通道数据集 * @param width 输出图像的宽度 */ export declare function mergeColorChannel(channels: colorChannels, width: number): ImageData; /** * 通过画布上的横纵坐标计算出像素在实际的通道中的下标 * @param x 横坐标 * @param y 纵坐标 * @param w 画布宽度 */ export declare function pos2index(x: number, y: number, w: number): number; /** * 通过实际的通道中的下标计算出像素在画布上的横纵坐标 * @param i 下标 * @param w 画布宽度 */ export declare function index2pos(i: number, w: number): Point; /** * 输出一个图像逐行访问的所有下标 * @param w 图像的宽度 * @param h 图像的高度 * @example * rowIndex(2,2); // [[0,1],[2,3]] * rowIndex(2,3); // [[0,1],[2,3],[4,5]] * rowIndex(3,2); // [[0,1,2],[3,4,5]] */ export declare function rowIndex(w: number, h: number): number[][]; /** * 输出一个图像逐列访问的所有下标 * @param w 图像的宽度 * @param h 图像的高度 * @example * colIndex(2,2); // [[0,2],[1,3]] * colIndex(2,3); // [[0,2,4],[1,3,5]] * colIndex(3,2); // [[0,3],[1,4],[2,5]] */ export declare function colIndex(w: number, h: number): any[]; /** * 统计数值数组arr中的相同数组出现的次数,返回一个map * @param arr 需要统计的数组 */ export declare function countArray(arr: number[]): Map; /** * 获取imageData中某个区域的内容 * @param x 左上角横坐标 * @param y 左上角纵坐标 * @param w 宽度 * @param h 高度 * @param imageData 需要去图像数据的原始图像 */ /** * 判断相等 * @param a 需要等于的值 */ export declare function isEq(a: any): (b: any) => boolean; export declare const eqT: (b: any) => boolean; /** * 创建一个canvas绘图对象 */ export declare const createCanvasContext2d: (width?: number, height?: number) => CanvasRenderingContext2D; /** * 合并多个数组 * @param arrs 需要合并的数据集 * @example * zip([[1,2,3],[4,5,6],[7,8,9]]); // [[1,4,7],[2,5,8],[3,6,9]] */ export declare function zip(arrs: any[][]): any[]; //# sourceMappingURL=utils.d.ts.map