City grid in Processing
December 14th, 2009
I’ve taken a small step towards generating a city layout in Processing, by implementing a boxing-algorithm to divide space into smaller spaces. This algorithm is actually a lot simpler than I thought it would be, and it leaves a lot of opportunity to randomize its behaviour. My code is rather ugly, but it is a recursive method that breaks out when either the width or height of the current square is below a certain value. When broken out, it fills the square. Otherwise it continues to divide the square into two.
Here is the result of a fully drawn grid:

And here is one where I tried to make the grid less obvious and more organic by leaving random plots empty:

All I need to do now is make the roads curved, so that the pattern doesn’t represent a modern city grid, but rather an ancient city center.
My name is Marco Hokke. My blog is about the things that interest me and things I might forget if I would not blog them.
Leave a Reply