开发者

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?

selecting a cell in a grid, spiral outwards through neighbour cells?


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜