UNPKG

@thi.ng/grid-iterators

Version:

2D grid and shape iterators w/ multiple orderings

47 lines 1.61 kB
import type { GridIterOpts2D } from "./api.js"; export interface DiagonalSlopeOpts extends GridIterOpts2D { /** * Diagonal slope / step size */ slope: number; } /** * Similar to {@link diagonalSlopeX}. Yields sequence of 2D grid coordinates in * diagonal order with configurable slope, starting at `[0,0]`. Each diagonal * starts at y=0 and progresses in +y direction and every `step` steps, one step * in -x direction. * * @example * ```ts tangle:../export/diagonal-slopey.ts * import { diagonalSlopeY } from "@thi.ng/grid-iterators"; * * // iterate grid in diagonals of 1:3 ratio (x:y) * console.log( * [...diagonalSlopeY({ cols: 5, rows: 5, slope: 3 })] * ); * // [ * // [0, 0], [0, 1 ], [0, 2 ], * // [1, 0], [1, 1 ], [1, 2 ], * // [0, 3], [0, 4 ], [2, 0 ], * // [2, 1], [2, 2 ], [1, 3 ], * // [1, 4], [3, 0 ], [3, 1 ], * // [3, 2], [2, 3 ], [2, 4 ], * // [4, 0], [4, 1 ], [4, 2 ], * // [3, 3], [3, 4 ], [4, 3 ], * // [4, 4] * // ] * ``` * * @param opts - */ export declare function diagonalSlopeY(opts: DiagonalSlopeOpts): Generator<import("./api.js").GridCoord2D, void, unknown>; /** * Similar to {@link diagonalSlopeY}. Yields sequence of 2D grid coordinates in * diagonal order with configurable slope, starting at `[step-1,0]`. Each * diagonal starts at y=0 and progresses in -x direction and every `step` steps, * one step in +y direction. * * @param opts - */ export declare function diagonalSlopeX(opts: DiagonalSlopeOpts): Generator<import("./api.js").GridCoord2D, void, unknown>; //# sourceMappingURL=diagonal-slope.d.ts.map