mar:
Hi coders,
I use the color red for a rectangle. If a predefined event happens I would like to make this red a bit darker. Mathematically spoken I would like to subtract C'50,50,50' from the normal color.
Is that somehow possible without setting a new color? Sometimes I don't know about the color of a rectangle and so I can't use absolute color values. I only want to make the current color a bit darker, whatever color it originally is.
Thanks!
I made this, not tested:
color darken(color mycolor,int c_offset) { int R=(mycolor%65536)%256; int G=((mycolor-R)%65536)/256; int B=(mycolor-(256*G)-R)/65536; if(R-c_offset>0) R-=c_offset; else R=0; if(G-c_offset>0) G-=c_offset; else G=0; if(B-c_offset>0) B-=c_offset; else B=0; return color(B*65536+G*256+R); }
Works perfect! Thank you very much!
mar:
Works perfect! Thank you very much!
You are welcome!
Works perfect! Thank you very much!
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hi coders,
I use the color red for a rectangle. If a predefined event happens I would like to make this red a bit darker. Mathematically spoken I would like to subtract C'50,50,50' from the normal color.
Is that somehow possible without setting a new color? Sometimes I don't know about the color of a rectangle and so I can't use absolute color values. I only want to make the current color a bit darker, whatever color it originally is.
Thanks!