Package Exports
- @thi.ng/grid-iterators
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@thi.ng/grid-iterators) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
@thi.ng/grid-iterators
This project is part of the @thi.ng/umbrella monorepo.
About
Collection of 2D grid iterators, providing the 10 following orderings:
Diagonal
Hilbert curve
Interleave columns
Supports custom strides... example uses step = 4
Interleave rows
Supports custom strides... example uses step = 4
Random
Supports custom PRNG implementations via IRandom
interface defined in
@thi.ng/random
Outward spiral
Z-curve
Zigzag columns
Zigzag diagonal
Zigzag rows
Some functions have been ported from Christopher Kulla's Java-based Sunflow renderer.
For more basic 2D/3D grid iteration, also see range2d()
& range3d()
in
@thi.ng/transducers.
Installation
yarn add @thi.ng/grid-iterators
Dependencies
Usage examples
import * as gi from "@thi.ng/grid-iterators";
[...gi.zigzagRows2d(4, 4)]
// [
// [ 0, 0 ], [ 1, 0 ], [ 2, 0 ], [ 3, 0 ],
// [ 3, 1 ], [ 2, 1 ], [ 1, 1 ], [ 0, 1 ],
// [ 0, 2 ], [ 1, 2 ], [ 2, 2 ], [ 3, 2 ],
// [ 3, 3 ], [ 2, 3 ], [ 1, 3 ], [ 0, 3 ]
// ]
Authors
- Karsten Schmidt
License
© 2019 Karsten Schmidt // Apache Software License 2.0