To make that possible we’ll mash up all that color stuff with Google Apps ScriptDB, and serve up color attributes as jSon or jsonp using Google Apps Script as described in Let Google Apps Script do the work. That way, we can get various palettes and their attributes by executing a simple rest query.
Get the colortable into ScriptDB
The colortable referenced in Playing around with GAS color is in a spreadsheet in Google Apps Script. Here’s how to load scriptDB with the data. We only need the name, key, scheme, hex code and reference code. All the other attributes will be computed at query time.
How to query
These examples will look up the color table and return the color characteristics.
- We can deal with multiple requests simultaneously – just separate them by a comma.
- Adding scheme= is optional, but can help if there is a duplication of code or name between schemes.
- You can use code= and name= and key= in the same query.
- If the same color is referred to multiple times, it will be repeated multiple times.
- Everything is case insensitive, and will anyway be converted to lower case
?key=pfh-blue fox,pfh-surf spray?name=blue fox,surf spray?scheme=pfh&name=surf spray,silver?code=17-4811 TCX&scheme=pfh?scheme=dulux&name=five star,fizz&code=P39G2 These will simply return the color characteristics of the given codes?rgb=213-210-220,219-0-12?hex=#fa1230,#1a2300
Regardless of the query, the response format is always the same
If you want beautfied JSON just add &beautiful
JSON or JSONP
By default, JSON will be returned. If you want JSONP just add
Transitioning is covered more comprehensively in my my book, Going Gas.
Continue reading about VBA to Google Apps Script here