Color selection

Hi,

I first came across this method of color selection in a formula called "RELATIVE PERFORMANCE" & if I remember correctly it was from the library, hence am not posting the formula in the forum.

Can some one kindly explain how this method of color selection works----

color = colorDarkRed + ( ( 2 * i ) % 15 ), the part after "+".

Thanks

I'll skip the first part of its uses and applications, and elasorate more on after the "+"

Basically, there is a sequence of numerically allocated values to pre-defined colors in AB.

You can see the full list here:
https://www.amibroker.com/guide/h_indbuilder2.html

starting with
ColorDarkRed = 24

now, the formula is such that whatever the value of I is, multiplied by 2 and so on can occur,
but the % is modulus, which also means the remainder of the division.

Basically, you can divide any number by 15 and modulus will have a fixed range of 0 to 14.

so 24 will dynamically be added with a number b/w 0 and 14 to generate a new color value in variable "color"
so you have a range of colors from
colorDarkRed = 24 to colorViolet = 38

4 Likes

Thanks a lot for the precise to the point explanation.