Wonderful set of features for working with colour! Thank you.
But, for full happiness, I lack the function of converting a number lying in a given interval to colour (and colour can be converted as you like with the help of your functions).
I use such a primitive construction:
//+------------------------------------------------------------------+ //|JQS RainbowColour v1.0.0| //|Copyright © 2010, JQS aka Joo. | //| http://www.mql4.com/ru/users/joo | //| https://www.mql5.com/en/users/joo | //+------------------------------------------------------------------+ color RainbowColor(double BrushIn,double min,double max) { string R,G,B; int temp; double Brush=ScaleColor(BrushIn,min,max,0.0,100.0); //If less than the lower limit if (Brush<0.0) { R="255"; G="0"; B="0"; return(StringToColor("C'"+R+","+G+","+B+"'")); } //If greater than the upper limit if (Brush>100.0) { R="255"; G="0"; B="255"; return(StringToColor("C'"+R+","+G+","+B+"'")); } //From red to yellow 255.0.0 -> 255.255.255.0 if (Brush>=0.0 && Brush<20.0) { R="255"; temp=(int)MathRound(ScaleColor(Brush,0.0,20.0,0.0,255.0)); G=(string)temp; B="0"; return(StringToColor("C'"+R+","+G+","+B+"'")); } //-------------------------------------------- //From yellow to green 255.255.0 -> 0.255.0 if (Brush>=20.0 && Brush<40.0) { temp=(int)(255.0-MathRound(ScaleColor(Brush-20.0,0.0,20.0,0.0,255.0))); R=(string)temp; G="255"; B="0"; return(StringToColor("C'"+R+","+G+","+B+"'")); } //-------------------------------------------- //Green to blue 0.255.0 -> 0.255.255.255 if (Brush>=40.0 && Brush<60.0) { R="0"; G="255"; temp=(int)(MathRound(ScaleColor(Brush-40.0,0.0,20.0,0.0,255.0))); B=(string)temp; return(StringToColor("C'"+R+","+G+","+B+"'")); } //-------------------------------------------- //From cyan to blue 0.255.255 -> 0.0.255 if (Brush>=60.0 && Brush<80.0) { R="0"; temp=(int)(255.0-MathRound(ScaleColor(Brush-60.0,0.0,20.0,0.0,255.0))); G=(string)temp; B="255"; return(StringToColor("C'"+R+","+G+","+B+"'")); } //-------------------------------------------- //From blue to violet 0.0.255 -> 255.0.255 if (Brush>=80.0 && Brush<=100.0) { temp=(int)(MathRound(ScaleColor(Brush-80.0,0.0,20.0,0.0,255.0))); R=(string)temp; G="0"; B="255"; return(StringToColor("C'"+R+","+G+","+B+"'")); } return(StringToColor("C'"+(string)255+","+(string)255+","+(string)255+"'")); } //+------------------------------------------------------------------+ double ScaleColor(double In,double InMIN,double InMAX,double OutMIN,double OutMAX) { double Out=((In-InMIN)*(OutMAX-OutMIN)/(InMAX-InMIN))+OutMIN; return(Out); } //+------------------------------------------------------------------+
The function returns the colour according to the rainbow colour scale.
Could you add this function to the library? - and improve it in terms of speed.
Wonderful set of features for working with colour! Thank you.
But, for full happiness, I lack the function of converting a number lying in a given interval to colour (and colour can be converted as you like with the help of your functions).
I use such a primitive construction:
The function returns the colour according to the rainbow colour scale.
Could you add this function to the library? - and improve it in terms of speed.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
IncColors:
This class contains functions for working with colors. It has color conversion and other useful functions.
List of functions:
Author: Дмитрий