LATEST NEWS ( April 7th 2015): Well this must have been a good idea, as Google have now incorporated Color Scale into the main conditional formatting feature.
The Color Scale add-on for Google Sheets sets the background color of the cells in a selected range according to their numeric value. This is similar to the ‘color scales’ or color gradient feature in Microsoft Excel. The lowest number found in the selection is set to the low color, the highest value to the high color and every value in between is colored dependant on their position between the high and the low.
Create a new Google Sheet on your Google Drive and install the Color Scale add-on (Add-ons>Get add-ons…). After installing it ‘Add-ons>Color Scale>Choose colors’ menu to select a low and high color for your selection of numbers, then use ‘Apply color scale to selection’ to apply the colors.
The source code is open source and available under GPL v3. Here is a spreadsheet that has v5 of the add-on code embedded, from which you can take a copy and see via Tools > Script editor.