You can see the terrain image in this spreadsheet.
Having just released the Color Scale Add-on I was having a play around with a terrain generator and created this (fairly) high-res terrain in a Google Sheet!
The terrain generation script is based on Hunter Loftis’ “Realistic terrain in 130 lines”, and just took a little tweaking to file the spreadsheet with a set of terrain height values. The script is embedded in this sheet that you can take a copy of to see the code. I’ve also put the code into a gist.
The terrain height values are generated by the diamond-square algorithm, which works on a square grid with sides (2 power n) + 1. Google sheet cells can be a minimum of 2 pixels so a 257×257 array fits on one page (2 power 8) + 1.
Creation
- Create a 257×257 Google Sheet (delete the excess rows and columns)
- Copy the terrain generation script into the sheet (or copy mine)
- Refresh the sheet to get the Terrain menu, and ‘Generate terrain map’ to fill all the cells with numeric values
- Install the Color Scale add-on (Add-ons,>Get add-ons…)
- Select your low and high colors (Add-ons>Color Scale>Chose colors)
- Select the whole sheet and apply the color scale (Add-ons>Color Scale>Apply color scale to selection)
- Delete the contents of the cells (this will just leave the background colours and allow the rows and columns to be reduced to their minimum size)
- Select all of the columns and re-size to 2 pixels (right-click, “Resize columns A – IW…”)
- Select all of the rows and and re-size to 2 pixels (right-click, “Resize rows 1 – 257 …”)
Pretty!
Wonder if it’s up for a bit of animation!
One thought on “High-res terrain generator in Google Sheet!”