Canvas is cool! - page 2

 
fxsaber:

CCanvas is a wrapper for ResourceCreate. So, for example, if you have 20 ready-made images in the form of arrays. If you want to change them through canvas, you will need to make expensive ArrayCopy+Update.

And if you do it without CCanvas, you will need ResourceCreate+ChartRerdraw only. I've posted several dynamic drawing jobs in kodobase. It was obvious there that CCanvas was no good.

I agree that it's a Resource wrapper. We need to settle on definitions. Canvas as I understand it, is not a CCanvas class, but a rectangular graphic resource, i.e. an array of points. What I need from CCanvas class is a few functions to create, update and delete. It's implemented quite intelligently, I see the other functions as useless due to the pixel (unsmoothed) implementation. Also, I am interested in kanvas as a vector graphics, not as a bitmap, ie in other words, when I form the image myself, rather than downloading pictures. Therefore I don't see any practical use for a 20 ready-made pictures and I can't use it as a video player with MT5. The aim of vector graphics is to render an image in less than 30 (or, better, less than 10) milliseconds. Since human eye won't see the image change more than 30 times per second anyway. Basically kanvas in MT5 copes with this task well. True, those colour swirls are at the limit (i.e. one frame is formed about 30 milliseconds on my average laptop), but on MT4 it's already slowing down.

I'm now making a CCanvasPro class as time permits, in which I want to make things a bit better.
Here's what I've got so far with the circles (smoothed with shadows). Sorry, I have not opened the code yet. Due to insufficient amount of free space.

This is also a script.

Files:
 
Evgeniy Zhdan:
Cool rainbow chart! I'd also like to make the candles dance to music and twist between themselves!

Will it increase profits?) A bonus for every dance, then I'm in.)))

 
Nikolai Semko:

Of course it will help, but there will be terrible braking.

There will be a slight slowdown, but no horrible braking. At least visually, nothing has changed.


 
Rashid Umarov:

There will be a slight slowdown, but no horrible braking. At least visually, nothing has changed.


Of course, I was a bit harsh. But still, it will be about 10% slower than overall performance.

 
Rashid Umarov:

There will be a slight slowdown, but no horrible braking. At least visually, nothing has changed.


Checked not on profiling, but withGetMicrosecondCount

It turned out 3-4% slowdown at 1000 frames. In principle, yes, not very critical.

while(!IsStopped())
     {
      static ulong t0=GetMicrosecondCount();
      int pos=int(i%size);
      if(pos==0)
        {
         C.Update();
         //Sleep(30);
         X1= Width-(sin((double)j/100)*(double)Width);
         Y1= Height-(cos((double)j/140)*(double)Height);
         X2= Width+(cos((double)j/80)*(double)Width);
         Y2= Height+(sin((double)j/20)*(double)Height);
         if (j==101000) Print(GetMicrosecondCount()-t0);
         j++;
        }
      int X=pos%Width;
      int Y=int(pos/Width);
      double d= ((X1-X)*(X1-X)+(Y1-Y)*(Y1-Y))/(((X1-X)*(X1-X)+(Y1-Y)*(Y1-Y))+((X2-X)*(X2-X)+(Y2-Y)*(Y2-Y)));
      //C.m_pixels[pos]=XRGB(h[int(d*11520)],h[int(d*17920)],h[int(d*6400)]);
      C.PixelSet(X,Y,XRGB(h[int(d*11520)],h[int(d*17920)],h[int(d*6400)]));
      i++;
     }


 
Nikolai Semko:

I set myself a task: to demonstrate the capabilities of custom graphics via CCanvas class in a short code.

Here's what came out of it.

This script works in both MQL5 and MQL4. But it is much faster on MT5.

Each frame is unique and does not repeat, i.e. the script is not cyclic.


You should move array m_pixels[] from protected: to public in Canvas.mqh before compiling:

half an hour watching, waiting for this thing to take off ))

 
Alexey Volchanskiy:

half an hour of watching, waiting for this thing to take off ))

:))
 

Frankly, I don't understand what the point is.

Well, yes, beautiful, colourful, iridescent... But how will it affect the work of the expert?

I would understand, if we were here to write the game - that's where such an opportunity oh, how demanded would be... But here...

In my opinion, it's necessary just the opposite - to get rid of any unnecessary actions, so that the resulting code would load the system as little as possible (would require money in the cloud). And it must also be easier to maintain.

Unless - "wow-effect" for customers... I think it's true, a nicely designed output allows you to make more money in Freelance...

 
Very cool, thank you, now the trade will go a lot brighter, literally.
 
George Merts:

Frankly, I don't understand what the point is.

Well, yes, beautiful, colourful, iridescent... But how will it affect the work of the expert?

I would understand, if we were here to write the game - that's where such an opportunity oh, how demanded would be... But here...

In my opinion, it's necessary just the opposite - to get rid of any unnecessary actions, so that the resulting code would load the system as little as possible (would require money in the cloud). And it must also be easier to maintain.

Unless - "wow-effect" for customers... I think, it's true, a nicely designed output lets you make more money in Freelance...

It might come in handy for indicators. There were different arrow indicators drawn here on the Canvas, there was even an article.