More playing around with color,, scriptDb and Google Apps Script

API for comparing colors

I continue to find the topic of comparing colors a fascinating one. As an experiment to see if I could create a REST API serving up JSON and JSONP from a Google Apps Script content service app, I wanted to see if I could create something that, given a color code, would find the nearest ‘n’ matching colors in some defined color scheme, such as pantone, dulux, htm colors and so on.

Just for fun, I also implemented the color database in both and scriptb.

A VBA consumer

Now all that is working, I needed to create something to act as a client. I have already implemented color matching natively in both VBA and Google Apps Script, but now I needed to create something that would delegate the database management and color matchs to a GAS web app and just query and display the results.

First off, here is the VBA version. Here’s the first 5 closest matching colors to some random hex codes from the pantone fashion and home library. I think the algorithm does a pretty good job – and all the processing is delegated off to the GAS modules described here.

For simplicity, Im using the rest/excel library to manage all the jSon stuff and web interaction details. That means that the final client procedure is rather trivial as below.



The only problem is that it is pretty slow. See here for a look at GAS performance. with a focus on lots of math. Using or scriptdb as the underlying database is not a big factor. I’ll publish some comparison stats on that later.

More color schemes

I’m looking for more color schemes. If you would like to contribute a color scheme, all i need is the link to a Google Document with the scheme in it, like the colortable tab in this spreadsheet.

You can download the VBA code and libraries mentioned here in the cDataSet.xlsm workbook – the colorschemer tab, from Excel liberation.

For more stuff like this, see from VBA to Google Apps Script, and for more detail on this post and how to use this as a REST API see colorschemer api

About brucemcp 225 Articles
I am a Google Developer Expert and decided to investigate Google Apps Script in my spare time. The more I investigated the more content I created so this site is extremely rich. Now, in 2019, a lot of things have disappeared or don’t work anymore due to Google having retired some stuff. I am however leaving things as is and where I came across some deprecated stuff, I have indicated it. I decided to write a book about it and to also create videos to teach developers who want to learn Google Apps Script. If you find the material contained in this site useful, you can support me by buying my books and or videos.

Be the first to comment

Leave a Reply

Your email address will not be published.


1 + 6 =