Skip to content

Latest commit

 

History

History

grid-iterators

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

@thi.ng/grid-iterators

npm (scoped) npm downloads Twitter Follow

This project is part of the @thi.ng/umbrella monorepo.

About

Collection of 2D grid iterators, providing the following orderings:

Diagonal Hilbert curve Outward spiral
anim anim anim
Zigzag columns Zigzag rows
anim anim

All functions have been ported from Christopher Kulla's Java-based Sunflow renderer.

For alternative 2D/3D grid iteration, also see range2d() & range3d() in @thi.ng/transducers.

Installation

yarn add @thi.ng/grid-iterators

Dependencies

None

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