The function of decomposing color into shades. - page 21

 
Реter Konow:

My algorithm works well. It's fast (15-20 microseconds). Yours doesn't work correctly. Are you suggesting that I should remake my algorithm by your example?)


That's it, Peter, you're boring me with your impenetrability.

I can't take it anymore.

I win. Your algorithm is perfect!

 
Nikolai Semko:


That's it, Peter, you're boring me with your impenetrability.

I can't take it anymore.

I win. Your algorithm is perfect!

Mine's not perfect. It's just more correct.

The moral of this fable is: neither syntax, nor language, nor style, nor compliance with standards rules! The developer rules.

 
Реter Konow:

Mine is not perfect. It's just more faithful.

OK your section in rgb space is straighter than mine.
 
Nikolai Semko:
OK your section in rgb space is more straightforward than mine.

Okay. The topic was interesting and useful.

 
The people were speechless...
 
Алексей Тарабанов:
The people were speechless...
Of course they did. There were no fools but me.
 
Nikolai Semko:
You bet. I'm the only one who's fooled.

Come on... A useful function was born:

Forum on trading, automated trading systems and trading strategy testing

Colour decomposition function.

Nikolai Semko, 2018.10.15 22:21

...

Here is the only necessary and more versatile function to work with gradient:

union rgb {uint clr; uchar c[4];};
void Gradient(uint clr1,uint clr2,uint &arr[],uint size)
  {
   if(size==0) return;
   ArrayResize(arr,size);
   arr[0]=clr1; 
   rgb c1,c2;
   c1.clr=clr1;
   c2.clr=clr2;
   double R1=c1.c[2],G1=c1.c[1],B1=c1.c[0];
   double R2=c2.c[2],G2=c2.c[1],B2=c2.c[0];
   double deltaR=(R2-R1)/(size-1);
   double deltaG=(G2-G1)/(size-1);
   double deltaB=(B2-B1)/(size-1);
   R1 += 0.4999;
   G1 += 0.4999;
   B1 += 0.4999;
   for(uint i=1;i<size;i++)
     {
      R1+=deltaR; c1.c[2]=uchar (R1);
      G1+=deltaG; c1.c[1]=uchar (G1);
      B1+=deltaB; c1.c[0]=uchar (B1);
      arr[i]=c1.clr;
     }
  }

As it generates all the algorithms given here in two lines. It is the fastest, as there is only one "+" operation in the loop, not even multiplication. Also this fuction gives blends of any two colours, not just calculates shades of one.


 
Artyom Trishkin:

Come on... A useful function was born:


Yes, but personally I'm unlikely to use it, as I'm stingy with generating an intermediate array of several KB for dynamic gradient. For static one it's certainly useful. But I have mostly dynamic ones and calculate gradient on the fly without arrays.
Anyway, Andrei Hatimlansky was right. Pyotr has been scamming me for time like a sucker.
 
Artyom Trishkin:

Come on... A useful function was born:

as it generates all the algorithms given here in two lines. It is the fastest, as there is only one "+" operation in the loop, not even multiplication. Also this fuction gives blends of any two colours, not just calculates shades of one.

Very possible... Colours, melodies and sounds... Current quotes and their changes, by the way, sound pretty good!

What do they look like in colour? And what would it be - colour harmony or cacophony?

 
aleger:

Very possibly... Colours, melodies and sounds... Current quotations and their changes, by the way, sound very good!

And what do they look like in colour? And what would it be - colour harmony or cacophony?

You gave Peter an idea. Let's see what kind of 'Petrophonia' it will be.