The function of decomposing color into shades. - page 20

 
prostotrader:
Can't you do tic-tac-toe?

With cool gradients and shades ))))

 
Sergey Basov:

With cool gradients and shades )))

I don't see what's so funny about that. It's very sad. The World has long been creating a cool form for a useless cause, and here they are still asking "why is it needed?". Needed to keep up with the World. Otherwise, - the World will crush it.

 
Реter Konow:

I don't see what's so funny about that. It's very sad. The world has long been creating a cool form for useless substance, and here they're still asking " why do we need it?". Needed to keep up with the World. Otherwise, - the World will crush it.

So prove that someone needs it (GUI, proper gradient, shades, etc), in the marketplace.

Cat and man have been hinting at this for a long time ))

PS. Nothing personal, I like nice interfaces too, but only as extras in MT.

 
Реter Konow:

I don't see what's so funny about that. It's very sad. The World has long been creating a cool form for a useless cause, and here they are still asking "why is it needed?". Needed to keep up with the World. Otherwise, - the World will crush it.

A cockroach dyed in all the colours of the rainbow, yes with shimmers, will not be crushed?

 
Sergey Basov:

Then prove that someone needs it (GUI, proper gradient, shades, etc.), in the marketplace.

Cat and man have been hinting at this for a long time ))

PS. Nothing personal, I like nice interfaces too, but only as extras in MT.

Who's there?

 
Реter Konow:

And to all this, I came by simply observing the behaviour of the numbers in the windows of the Windows palette.

I use a different method. I just incorporate knowledge-based logic.

And you still don't seem to understand that we have the same algorithm, because there's no other. The algorithm is called - linear function connecting two points in three-dimensional space (x1,y1,z1) and (x2,y2,z2)

http://www.cleverstudents.ru/line_and_plane/canonical_equations_of_line_in_space.html

Only for some reason, judging by your very first message, it took you a month to create it, and even with mistakes, while I didn't even have to invent anything, because it's obviously a simple problem connecting two points in three dimensions (r1,g1,b1) and (r2,g2,b2), which I know and understand very well from school, not even at formula level, but at logic level. The first realization took me about 15 minutes and the code worked from the first (I don't remember, maybe from the second) time.

I already wrote here that your algorithm is implemented using a simpler and more versatile function as follows:

   color clr=clrViolet;
   uint CLR1[],CLR2[];
   Gradient(clrWhite, clr, CLR1,128); // получаем массив из 128 элементов градиента от белого цвета до цвета clr 
   Gradient(clr, clrBlack, CLR2,127); // получаем массив из 127 элементов градиента от цвета clr до черног цвета  

A common array of two arrays CLR1 and CLR2 is your solution.

My solution was, slightly more complicated, because you need to calculate the colour lightness and substitute it instead of 128 and 127.

So once again, this is the last one to repeat.
Here's the only gradient function you need, and it's more versatile:

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. It also gives blends of any two colours, not just calculates shades of one.

 
Nikolai Semko:

I use a different method. I just use knowledge-based logic.

And you still don't seem to understand that there is only one algorithm, because there is no other. The algorithm is called - linear function connecting two points in three-dimensional space (x1,y1,z1) and (x2,y2,z2)

http://www.cleverstudents.ru/line_and_plane/canonical_equations_of_line_in_space.html

Only for some reason, judging by your very first message, it took you a month to create it, and even with mistakes, while I didn't even have to invent anything, because it's obviously a simple problem connecting two points in three dimensions (r1,g1,b1) and (r2,g2,b2), which I know and understand very well from school, not even at formula level, but at logic level. The first realization took me about 15 minutes and the code worked from the first (I don't remember, maybe from the second) time.

I already wrote here that your algorithm is implemented using a simpler and more versatile function as follows:

A common array of two arrays CLR1 and CLR2 is your solution.

My solution was a bit more complicated as I need to calculate the colour lightness and substitute it instead of 128 and 127.

so I'll repeat it one last time.
Here's the one and only needed and more versatile function for working with a gradient:

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.

We have different algorithms and different approaches. I don't have any linear function connecting two points in three-dimensional space. I have a two-dimensional graph with six segments forming a prism.

Your one and only function doesn't give the right range of colours. I've already shown and proven it.

 
Artyom Trishkin:

A cockroach coloured in all the colours of the rainbow, yes with shimmers, won't get crushed?

You don't have to worry about that.

 
Реter Konow:

We have different algorithms and different approaches. I don't have any linear function connecting two points in three-dimensional space. I have a two-dimensional graph with six segments forming a prism.

Your one and only function does not give the right range of colours. I've already shown and proven that.

You're just making a mess, but if you simplify your creation, you'll get what I wrote. That's why your work of art is slower and works, because you've messed up so much that you can even calculate digit 2 through a tangent.
Check on the basis of Yuri's code taking your algorithm and this one from my previous post. And you will see that it will be identical, only much faster and much shorter.

 
Nikolai Semko:

You just made a mess of things, but if you simplify your creation, you will get what I've written about. That's why your work of art is slower, because you made up so much stuff, that you can calculate number 2 through tangent.
Check on the basis of Yuri's code and take your algorithm from my previous post . You will see that it will be identical, only much faster and much shorter.

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

You helped me make my algorithm faster, so I didn't have to rewrite it. Thanks for that. Otherwise, my algorithm needs nothing but cosmetic fixes.

However, there are obvious problems with your algorithm.