Would you admit that you've made a lot of noise out of nothing? Yes, the algorithm may be slower than yours and it had a couple of bugs. It's not debugged on MT5 yet. But it works.
A good example of how not to program. If this is how your entire GUI is written, we won't be seeing it for a while. :(
Every line is a "masterpiece": such a pile of errors and bloopers, so much hope that mql4 will work out. I now understand why mt4 is being used.
I think that publishing of such codes and the subsequent reaction to criticism is not respecting the forum audience. They don't want to do you harm, they want to help you.
As for comparing algorithms, you can compare them visually. It's not like you offered proof in numbers that your algorithm gives shades 99% close to "windows shades".
On the left is sort of your approach, on the right isNikolai Semko's. (A modified NikolaiSemko script was used)
Thank you, Yuri, for your participation and understanding of the matter, as well as for the clear example. After your changes my code became more pleasant to look at.
But here is a small clarification:
int x;//индекс исходного цвета в массиве оттенковif(_mode==0) x=(clr.x[ArrayMaximum(clr.x,0,3)]+clr.x[ArrayMinimum(clr.x,0,3)])/2; // Светлота= (MAX+MIN)/2 Вариант из https://ru.wikipedia.org/wiki/HSL. Тот вариант к которому изначально стремился Петр.if(_mode==1) x=(int)round((clr.rgb.b+clr.rgb.g+clr.rgb.r)/3.0); // мой вариант, который мне кажется более логичным и правильнымif(_mode==2) x=127; // То, что в результате получилась у Петра из-за его алгоритмической путаницы. У него цветовой "сгусток" не гуляет, а стоит ровно по центру.
Thank you, Yuri, for your participation and insight, as well as for the clear example. After your changes my code became more pleasant to look at.
But here is a little clarification:
Maybe so :)
int ColorShades(uint _clr,uint& _shades[],int _mode=0)
{
SuintRGB clr;
if(ArrayResize(_shades,256)!=256) return(-1); //ошибка resize()
clr.clr=_clr;
int x;//индекс исходного цвета в массиве оттенковif(_mode==0) x=(ArrayMaximum(clr.x,3)+ArrayMinimum(clr.x,3))/2; // Светлота= (MAX+MIN)/2 Вариант из https://ru.wikipedia.org/wiki/HSL. Тот вариант к которому изначально стремился Петр.
else if(_mode==1) x=(int)round((clr.rgb.b+clr.rgb.g+clr.rgb.r)/3.0); // мой вариант, который мне кажется более логичным и правильным
else x=127; // То, что в результате получилась у Петра из-за его алгоритмической путаницы. У него цветовой "сгусток" не гуляет, а стоит ровно по центру.double d, kr, kg, kb;
if(x>0)
{
//движение от черного
d=double(x);
kr=clr.rgb.r/d;
kg=clr.rgb.g/d;
kb=clr.rgb.b/d;
for(int i=0; i<=x; i++)
{
clr.rgb.r=(uchar)fmin(255,kr*i);
clr.rgb.g=(uchar)fmin(255,kg*i);
clr.rgb.b=(uchar)fmin(255,kb*i);
_shades[i]=clr.clr;
}
}
if(x<255)
{
//движение от белого
d=double(255-x);
kr=(255-clr.rgb.r)/d;
kg=(255-clr.rgb.g)/d;
kb=(255-clr.rgb.b)/d;
for(int i=255, j=0; i>x; i--, j++)
{
clr.rgb.r=(uchar)fmax(0,255.0-kr*j);
clr.rgb.g=(uchar)fmax(0,255.0-kg*j);
clr.rgb.b=(uchar)fmax(0,255.0-kb*j);
_shades[i]=clr.clr;
}
if(x==0) _shades[0]=0;
}
return(x);
}
Yes, there is a mistake. Didn't notice it. Reaches white by the middle of the range, although the colour belongs to the grey range. So it should go to white gradually.
After that you shouldn't wonder why your code is so much slower.
Generally, it's convenient to take someone else's proven code and, covered by its impeccability, tell others (who are looking for a solution with their minds) how much better you are. Isn't it so, Nicolai?)
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
Check your algorithm for colour 0,0,0 and 255,255,255.
I will check it now.
Check your algorithm for colour 0,0,0 and 255,255,255.
Checked. 0,0,0,0, - causes an error. Advisor's unloading.
255,255,255 is fine.
Thank you for this observation. I'll look into it.
What do you think, Nikolai?
Would you admit that you've made a lot of noise out of nothing? Yes, the algorithm may be slower than yours and it had a couple of bugs. It's not debugged on MT5 yet. But it works.
Do you even realize that code like this
is 100% the same as this one:
After that, you shouldn't wonder why your code is so much slower.
255,255,255 is fine.
Is this consistent with 99% "windows shades"?
I'll join the 'accusations', couldn't take it :)
A good example of how not to program. If this is how your entire GUI is written, we won't be seeing it for a while. :(
Every line is a "masterpiece": such a pile of errors and bloopers, so much hope that mql4 will work out. I now understand why mt4 is being used.
I think that publishing of such codes and the subsequent reaction to criticism is not respecting the forum audience. They don't want to do you harm, they want to help you.
As for comparing algorithms, you can compare them visually. It's not like you offered proof in numbers that your algorithm gives shades 99% close to "windows shades".
On the left is sort of your approach, on the right isNikolai Semko's. (A modified NikolaiSemko script was used)
Thank you, Yuri, for your participation and understanding of the matter, as well as for the clear example. After your changes my code became more pleasant to look at.
But here is a small clarification:
Thank you, Yuri, for your participation and insight, as well as for the clear example. After your changes my code became more pleasant to look at.
But here is a little clarification:
Maybe so :)
Do you even realize that code like that
is 100% the same as this one:
After that you shouldn't wonder why your code is much slower.
Well, that's the stupidity of not understanding my algorithm.
Maybe so :)
Yeah.
Only I made a mistake at the beginning and have already corrected it in a previous post
Is this in line with 99% of the "Windows shades"?
Yes, there is a mistake. Didn't notice it. Reaches white by the middle of the range, although the colour belongs to the grey range. So it should go to white gradually.
...
After that you shouldn't wonder why your code is so much slower.
Generally, it's convenient to take someone else's proven code and, covered by its impeccability, tell others (who are looking for a solution with their minds) how much better you are. Isn't it so, Nicolai?)