I must admit that I never really thought about how Qlik handled colors internally and how they are stored. Inspired by the following discussion: https://community.qlik.com/thread/297454 I looked a bit more closely and I'm not really surprised to detect that colors are dual-values which meant something like this:
Of course I could have known it because it is clearly stated within the help but usually I look only to the examples and don't read the descriptions …
This meant they are logically handled like date-values in which each date get a certain number assigned and a displaying of 2018/04/10 is just a formatting of a numerical value. Further because of the statement that Qlik used the color-logic of Visual Basic I assume that Qlik just used Microsoft *.dll's for it without implementing own logics.
How this worked could be comprehend with the following script - the attached qvw contained only a reduced dataset because most of the fields produce distinct values and by 16.8 M of records the filesize will be quite heavy:
This script creates with a nested loop (1 x autogenerate + 2 while) all possible combinations of the rgb-colors = 256 *256 *256 = 16,777,216 records (if you removed the first statement) and builds with them the colors as string-, numeric- and dual-value. On top of it are additionally clusters, color-functions which use the record-number as color-index and a function (with the help of the above variables) which calculates reverse from the color-index the rgb-notation.
And instead of rgb() or color-function like white() you could just use the color-index to specify your wanted color. Further included is a similar (reduced) logic for argb() to display why the rgb-index starts with an offset from 4,278,190,080 because the color-index for argb() starts by 1 and need all these numbers. You should comment or drop fields which have no real use for you to keep the application handy.
The clusters are just aimed to provide a selection possibility to certain areas with which the size of a table in the UI could be reduced because without any selection it might take some time for calculating and rendering the objects.