More playing around with color, parse.com, 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 parse.com 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.

 Performance

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 Parse.com 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

(function() {
var po = document.createElement(‘script’); po.type = ‘text/javascript’; po.async = true;
po.src = ‘https://apis.google.com/js/plusone.js’;
var s = document.getElementsByTagName(‘script’)[0]; s.parentNode.insertBefore(po, s);
})();

Author: brucemcp

Leave a Reply

Your email address will not be published. Required fields are marked *