selecting a cell in a grid, spiral outwards through neighbour cells?
I would like to accomplish two things with this:
Select (any) cell开发者_如何学C from a grid, and give the 'bands' of neighboring cells an ever increasing value (in this example 1 -5)
From the selected cell, select the next cell in a spiral fashion as show in blue, also accounting for if the 'route' leave the grid.
How would I go about this?
From your picture, you don't actually have to do it in spiral. The picture just shows, so to say, concentric circles (or, rather, squares).
You can calculate the next concentric square easily by subtracting or adding one to left/top or right/bottom edge coordinate correspondingly.
精彩评论