ColorFactory. Based on snippets from https://github.com/ndp/jsutils.git