Added a few functions to gameobjects.util that seemed worth sharing. The first two are two-dimensional versions of range
and xrange
. When iterating over something 2 dimensional (such as pixels in an image) you typically have an outer loop for the y coordinate, and an inner loop for the x coordinate. The range2d
and xrange2d
functions combine these two loops in to one and take range iterables as parameters.
Here's how you might use range2d
to iterate over the coordinates in an image.
The xrange2d
function returns a generator rather than a list, but works the same. continue reading…