Canvas is cool! - page 47

 
Maxim Kuznetsov:

not a circle on a plane, but a cylinder in 3d :-) The course will come out in a spiral. If you successfully mark up the cylindrical coordinates, it's a pretty sensible thing

Possibly.
 
Maxim Kuznetsov:

Then not a circle on the plane, but a cylinder in 3d :-) The course will come out in a spiral. If you successfully mark up the cylindrical coordinates, it's a pretty sensible thing

It's actually not at all difficult to implement. 2-5 lines of code in addition. If no one has done it before me, when I have a spare minute, I'll do it.

But it's better to have a 4K screen

 
Maxim Kuznetsov:

then not a circle on a plane, but a cylinder in 3d :-) The course will come out in a spiral. If you successfully mark up the cylindrical coordinates, it's a pretty sensible thing

https://www.mql5.com/en/code/27662

Note the speed and size of the code.
And that's all without Direct X

 
Nikolai Semko:

https://www.mql5.com/en/code/27662

Note the speed and size of the code.
And that's all without Direct X

Magical!

What does the radius depend on?

Is it difficult to make the ring multicoloured?

Perhaps this visualisation would be useful for evaluating the best 50 passes in optimisation, or the whole optimisation in compaction.

 
Nikolai Semko:

https://www.mql5.com/en/code/27662

Note the speed and the size of the code.
And that's all without Direct X

Simply, magic. !!!

And if you add a polar grid to the axis, and the ability to change the scale, up to almost straight "parallels" (and parallel "meridians" )), you get a smooth transition to traditional graphics.

 
Nikolai Semko:

https://www.mql5.com/en/code/27662

Note the speed and size of the code.
And that's all without Direct X

+++
 

Thank you all!


Aleksey Vyazmikin:

It's magical!

What does the radius depend on?

Is it difficult to make the ring multicoloured?

Perhaps this visualisation would be useful for evaluating the best 50 passes during optimisation, or the whole optimisation during compaction.

The code for this 3D graphics and rotation control fits all in this function:

void Draw(double &c[]) {
   double _r=_Height/2-7;
   int Per=int(2*M_PI*_r);
   int X=_Width/2;
   int Y=_Height/2-5;
   double K=10*_Height;
   Canvas.Erase(0xFF000000);
   int Size =ArraySize(c);
   double max = c[ArrayMaximum(c,0)];
   double min = c[ArrayMinimum(c,0)];
   if (max-min<=0) return;
   double _a=2*M_PI/per*(_Width/2  - _MouseX + 5*per); // угол камеры по горизонтали (_MouseX  - текущая координата X указателя мышки)
   double _b=2*M_PI/per*(_Height/2 - _MouseY + 5*per); // угол камеры по вертикали   (_MouseY  - текущая координата Y указателя мышки)
   for (int i=0; i<Size; i++) {
      double r = _r*(0.3+0.7*(c[i]-min)/(max-min));
      double a = 2*M_PI/per*i;
      double z =r -r*2*double(i)/Size;
      double x = cos(a)*r;
      double y = sin(a)*r;
      double R=sqrt(x*x+y*y+z*z);
      double x1=x*cos(_a)+z*sin(_a);
      double z1=-x*sin(_a)+z*cos(_a);
      double y1=y*cos(_b)+z1*sin(_b);
      double z2=-y*sin(_b)+z1*cos(_b);
      z2=z2+_r;
      x=X+K*x1/(z2+K);
      y=Y+K*y1/(z2+K);
      _PixelSet((int)x,(int)y,Grad(double(i)/Size));
   }
   Canvas.Update();
}

The input to this function is only an array of prices. Even a schoolboy can understand the code. A one-dimensional price array is converted into a 3-dimensional array of points. In the XY plane the price is represented in the polar coordinate system, where the distance r=sqrt( x2+y2) to the centre (0,0) is the price value.

The colour selection is the responsibility of this function:

uint Grad(double p) {
   static uint Col[6]= {0xFF0000FF,0xFFFF00FF,0xFFFF0000,0xFFFFFF00,0xFF00FF00,0xFF00FFFF};
   if(p>0.9999) return Col[5];
   if(p<0.0001) return Col[0];
   p=p*5;
   int n=(int)p;
   double k=p-n;
   argb c1,c2;
   c1.clr=Col[n];
   c2.clr=Col[n+1];
   return ARGB(255,c1.c[2]+uchar(k*(c2.c[2]-c1.c[2])+0.5),
               c1.c[1]+uchar(k*(c2.c[1]-c1.c[1])+0.5),
               c1.c[0]+uchar(k*(c2.c[0]-c1.c[0])+0.5));
}

whose input p is a number from 0 to 1, and whose output is the selected gradient colour. The skeleton of the colour pattern itself in this case consists of 6 colours (array Col)

You are free to colour in any way you want and in any way you want

 
Aleksey Panfilov:

Simply, magic. !!!

And if you add a polar grid to the axis, and the ability to change the scale, up to almost straight "parallels" (and parallel "meridians" )), you get a smooth transition to the traditional graph.

Sure, but I don't want to clutter up the code with different scales. In this case it was important for me to show the code which doesn't contain anything superfluous. So that it would be easier to understand it.

 
Nikolai Semko:

Sure, but I don't want to clutter up the code with different scales. In this case, it was important for me to show the code without anything superfluous. It would be easier to understand it.

Nikolay, a question about your library, how to take data into the Expert Advisor?

 
Martingeil:

Nikolay, a question about your library, how to take data into the Expert Advisor?

I don't understand the question. iCanvas is a graphics library.
You are probably asking how to read data into EA if you create an indicator with line visualization via iCanvas and leave it bufferless? Then please express yourself more clearly.

First of all, no one forbids you to create buffer indicator arrays, as in a standard indicator, but simply make them INDICATOR_CALCULATIONS and then access the data through iCustom in the usual way.

Secondly, there is such a powerful tool, as resources. Indicator buffers are essentially the same resources. Anyway, they use the same mechanism of storage and access to the data.

Deal with resources. It's not very straightforward, but it's an important tool for transferring data. You can create your own libraries which are more efficient than the classic buffer arrays.

Personally, I use my own designs, which I don't publish. They are more convenient and efficient than the iCustom access. Everything is implemented exactly through the resources.

Reason: