The function of decomposing color into shades. - page 19

 

I'm sorry, Pyotr - I'll take it from here. I've already said all I have to say on the subject. I have no desire to repeat myself.

There are no your and my algorithms.

I repeat, the only thing worthy of attention in this thread is this function, from which "your" and "my" algorithms can be derived, the rest is handwashing (both from your side and mine:))

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;
     }
  }
 
Nikolai Semko:

I'm sorry, Pyotr - I'll take it from here. I've already said all I have to say on the subject. I have no desire to repeat myself.

There are no your and my algorithms.

Again, the only thing worthy of attention in this thread is this function from which you can get "your" and "my" algorithms, the rest is handwashing (both from your side and mine :))

Nikolai, I'm all for objectivity. I have attached the script and screenshots.

I know you like to improve your solutions. So do I.

Your algorithm (unfortunately) creates the wrong gradient. I didn't look for the error in it because I don't know how it works. But you can do it.

 
Реter Konow:

Nikolai, I'm all for objectivity. I have attached a script and screenshots.

I know you like to improve your solutions. So do I.

Your algorithm (unfortunately) creates the wrong gradient. I didn't look for the error in it because I don't know how it works. But you can do it.

https://www.mql5.com/ru/forum/282861/page7#comment_8971634

https://www.mql5.com/ru/forum/282861/page9#comment_8987611

https://www.mql5.com/ru/forum/282861/page11#comment_8987978

https://www.mql5.com/ru/forum/282861/page19#comment_9019253
 

Yes, you think your algorithm works correctly because it fits your theory of how it works correctly. I get that.

However, I take the Windows palette as my benchmark. If you compare the output of your algorithm to the palette, the difference is significant. You can see it in the numbers and visually.

That's all I wanted to show.

You may leave it like that. It also looks nice that way.

 
Реter Konow:

Yes, you think your algorithm works correctly because it fits your theory of how it works correctly. I get that.

However, I take the Windows palette as my benchmark. If you compare the output of your algorithm to the palette, the difference is significant. You can see it in the numbers and visually.

That's all I wanted to show.

You may leave it like that. It is also beautiful.

You don't see what I'm writing. I don't like the approach I took, which you call my algorithm myself (less evil). But I dislike your approach even more and I have explained why.

 
Nikolai Semko:

you don't see what I'm writing. The approach I took, which you call my algorithm, I don't like myself (less evil). But I dislike your approach even more and I explained why.

Well, then you don't like the Windows palette either. After all, I have an almost complete match with it.

 
Реter Konow:

Well, then you don't like the Windows palette either. After all, I have an almost perfect match with it.

I already wrote about that.

And don't confuse palette and gradient. The gradient is one dimensional, the palette is two or three, or four dimensional (if you're talking about CMYK).

For example:

it's a two-dimensional red palette

and this is its one-dimensional gradient.

You're trying to argue about where the junction of the two gradients (from black to colour and from colour to white) is needed. You argue that the variants in the middle are the only correct ones, as they are used in Paint in Windows. In your examples above, where only one colour component appears and the others are 0, yes - it is more correct, but it is only a special case. I'm not asserting anything, I'm just saying that it depends on the task at hand, but I think it is logical to set it in the most general case, depending on the luminosity of the colour (the sum of R+B+G).

For example, in more serious graphics editors, such as those from Corel and Adobe, when it comes to gradient fills, there is a setting for the "center of gravity" of the gradient:

it's a no-brainer argument.

I'm catapulting off this topic.

 
Nikolai Semko:


I'm talking about the colour range. The gradient can be different. But the full range of shades of a single colour is constant.

Each colour has three components - three points on a graph. There are three lines through them. Each line has two segments on the graph. The segments appear from the refraction of light. The axis of refraction is in the centre of the graph. Each segment has a different angle of ascent. The ascent goes from zero to the maximum value. All six segments on the chart represent a prism. Their angles are constant for each range. The task is to find the value of a component in each point of the bars. In this way, I find all shades of one colour. Everything else is derivative manipulation of this solution. You can change the angles of ascent, you can mix colours, and so on. The basis remains the same.

In your solution, the range of shades is either incomplete or distorted. In either case, the transition of shades is not smooth and harmonious.


zy. About the centre of gravity - I agree. But it's just a manipulation of calculating specific points on the graph. You can get more component values in the first segment than in the second. That's how you get a "shifted centre of gravity gradient" (like the example above).

 
Can't you do tic-tac-toe?
 

The graph looks something like this:



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