Of course, Load/Unload/Activate etc. are custom, but since you have this event-core, you have way more flexibility than without and way more control over absolutely everything. If I´d had the time, I would write an article and provide the sources. Its not a secret, no magic at all.
Thank you. No, no libraries. I developed it from scratch myself. Actually, only CCanvas is adapted from the original ones, nothing else.
It's not easy to make something like this. )
As far as I know, in the standard Ccanvas class there is no functionality for drawing a colour gradient, how did you solve the problem with a gradient in your GUI?
Реter Konow #: It's not easy to make something like this. )
As far as I know, in the standard Ccanvas class there is no functionality for drawing a colour gradient, how did you solve the problem with a gradient in your GUI?
You mean the light-effects? Well, added light :D As described, CCanvas is also only adapted in its basics and its structure, not in its details.
//+------------------------------------------------------------------+
//| Macro to generate color |
//+------------------------------------------------------------------+
#define XRGB(r,g,b) (0xFF000000|(uchar(r)<<16)|(uchar(g)<<8)|uchar(b))
#define ARGB(a,r,g,b) ((uchar(a)<<24)|(uchar(r)<<16)|(uchar(g)<<8)|uchar(b))
#define TRGB(a,rgb) ((uchar(a)<<24)|(rgb))
#define GETRGB(clr) ((clr)&0xFFFFFF)
#define GETRGBA(clr) uchar((clr)>>24)
#define GETRGBR(clr) uchar((clr)>>16)
#define GETRGBG(clr) uchar((clr)>>8)
#define GETRGBB(clr) uchar(clr)
#define COLOR2RGB(clr) (0xFF000000|(uchar(clr)<<16)|(uchar((clr)>>8)<<8)|uchar((clr)>>16))
#define RGB2COLOR(rgb) ((uchar(rgb)<<16)|(uchar((rgb)>>8)<<8)|uchar((rgb)>>16))
//+------------------------------------------------------------------+//| Add light to rectangular area |//+------------------------------------------------------------------+void CCanvasExt::AddLight(int x1, int y1, int x2, int y2, bool updown=true, double intensity=.5, int isoftedge=20, color lightcolor=C'255,255,255')
{
if (intensity==0)
return;
int tmp;
//--- sort vertexesif(x2<x1)
{
tmp=x1;
x1 =x2;
x2 =tmp;
}
if(y2<y1)
{
tmp=y1;
y1 =y2;
y2 =tmp;
}
//--- out of screen boundariesif(x2<0 || y2<0 || x1>=m_width || y1>=m_height)
return;
//--- stay withing screen boundariesif(x1<0)
x1=0;
if(y1<0)
y1=0;
if(x2>=m_width)
x2=m_width -1;
if(y2>=m_height)
y2=m_height-1;
//--- calculate softedge
isoftedge=MIN(100,isoftedge);
int softedge=isoftedge>0 ? isoftedge*(y2-y1)/100 : 0;
//--- correct height
y2-=(y2-y1)/2;
y2+=(softedge/2);
y2++;
y2=MIN(m_height-1,y2);
//--- prepare
COLOR_RGBA rgb=_ColorLumaMult(lightcolor,ABS(intensity));
double r=(int)GETRGBR(rgb);
double g=(int)GETRGBG(rgb);
double b=(int)GETRGBB(rgb);
if (intensity<0)
{
r=0-r;
g=0-g;
b=0-b;
}
uint pixel;
int istart;
int iend;
int i;
//--- check directionif (updown)
{
//--- add main light for(;y1<y2-softedge;y1++)
{
istart=y1*m_width+x1;
iend=istart+(x2-x1);
for (i=istart;i<=iend;i++)
{
pixel=m_pixels[i];
m_pixels[i]=ARGB(GETRGBA(pixel),MIN(GETRGBR(pixel)+r,0xFF),MIN(GETRGBG(pixel)+g,0xFF),MIN(GETRGBB(pixel)+b,0xFF));// m_pixels[i]+=XRGB(r,g,b);//m_pixels[i]|=rgb;
}
}
if (softedge==0)
return;
//-- Add soft edge double decr=r/softedge;
double decg=g/softedge;
double decb=b/softedge;
//--- Loop rows separate and adjust color each row for (;y1<=y2;y1++)
{
r-=decr; r=MAX(0,r);
g-=decg; g=MAX(0,g);
b-=decb; b=MAX(0,b);
istart=y1*m_width+x1;
iend=istart+(x2-x1);
for (i=istart;i<=iend;i++)
{
pixel=m_pixels[i];
m_pixels[i]=ARGB(GETRGBA(pixel),MIN(GETRGBR(pixel)+r,0xFF),MIN(GETRGBG(pixel)+g,0xFF),MIN(GETRGBB(pixel)+b,0xFF));// m_pixels[i]+=XRGB(r,g,b);
}
}
}
}
Doerk Hilger #: You mean the lighting effects? Well, added light :D As said, CCanvas is also adapted only in the basics and structure, but not in the details.
Feel free to use it :) PS: updown is actually useless as far as I can see. In any case, the light usually comes from above.
Yes, you have an interesting option, I'll try it :)
I have the light distribution working the other way round - from a given original colour to a lighter one. Let me explain: the colour partitioning algorithm itself works correctly and writes 256 shades to the array. That is, the full range for each colour that the function accepts. But the painting algorithm puts the gradient on the surfaces of elements only in one direction. For a long time I wanted to add features, and make multidirectional gradient, which would give volume and complex plane elements. In principle, this is not a difficult task. However, there are many more important tasks ahead).
And a final EA looks like this then:
If I´d had the time, I would write an article and provide the sources. Its not a secret, no magic at all.
Watched the GUI you created. I like it a lot. Tell me, did you write it yourself or did you use some MQL libraries?
Thank you.
No, no libraries. Designed from the scratch by myself. Actually only CCanvas from the original ones is adapted, nothing else.
Thank you.
No, no libraries. I developed it from scratch myself. Actually, only CCanvas is adapted from the original ones, nothing else.
It's not easy to make something like this. )
You mean the light-effects? Well, added light :D As described, CCanvas is also only adapted in its basics and its structure, not in its details.
I see, thanks. )
Feel free to use it :)
PS: updown is actually useless, as I see. Anyway, light comes from above anyway usually
Feel free to use it :)
PS: updown is actually useless as far as I can see. In any case, the light usually comes from above.