Библиотеки: Easy Canvas - страница 12

 
Mighty7:

That's not working because my Canvas is the fullscreen. It's like a tick chart but it cost too much time to erase the complete background and construcht and paint everything new so I need to move the content to the left (eg. 8 pixels) and draw only the new 8 pixels (8 px in x direction and full height)  with new data. I tried to move the Canvas 8 px to the left with MoveCanvas and this is working but I can't resize it the way that from the left 8 px width are removed and on the right 8 px are added. I hope you understand...

Mighty7:

That's not working because my Canvas is the fullscreen. It's like a tick chart but it cost too much time to erase the complete background and construcht and paint everything new so I need to move the content to the left (eg. 8 pixels) and draw only the new 8 pixels (8 px in x direction and full height)  with new data. I tried to move the Canvas 8 px to the left with MoveCanvas and this is working but I can't resize it the way that from the left 8 px width are removed and on the right 8 px are added. I hope you understand...

Ок, сделал. Скачайте себе версию 1.42.
Но необходимо контролировать изменение масштаба по вертикали.

Ok, done. Download version 1.42 for yourself.
But you need to control the change in vertical scale.

#include <Canvas\iCanvas.mqh> //https://www.mql5.com/ru/code/22164

input int shift = -1;
//+------------------------------------------------------------------+
int OnInit() {
   EventSetMillisecondTimer(100);
   Canvas.Erase(0x00FFFFFF);
   return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
void OnTimer() {
   Canvas.FillCircle(rand()%_Width,rand()%_Height, 10+rand()%100,Canvas.Grad(rand()/32767.0)&0x80FFFFFF);
   Canvas.ShiftCanvas(shift);
   Canvas.Update();
   
}
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
                const int prev_calculated,
                const int begin,
                const double &price[]) {
   return(rates_total);
}
void              ShiftCanvas(const int _shift=-1, uint bckgr = 0x00FFFFFF) { // shift the entire canvas to the left (x is a negative value) or to
                     // the right (x is a positive value). The canvas itself remains in place, but all pixels are shifted. The bckgr is 
                     // the color with which the newly created stripe is filled to the left or right, depending on the direction of the shift.
                        if (_shift==0) return;
                        int _Shift = Fabs(_shift);
                        if (_Shift>=m_width) { ArrayInitialize(m_pixels,bckgr); return;}
                        int start = (_shift>0)?0:-_shift;
                        int count = m_width-_Shift;
                        int offset= (_shift>0)?0:count;
                        for (; start<m_height*m_width; start+=m_width, offset+=m_width) {                        
                           ArrayCopy(m_pixels,m_pixels,start+_shift,start,count); 
                           ArrayFill(m_pixels,offset,_Shift,bckgr);
                        }                        
                     }



Файлы:
 
Great. Thank you very much. 
 
Mighty7:
Great. Thank you very much. 
No problem 😊
 
Nikolai Semko:
No problem 😊

It works like a charme but to have it complete, is it possible to implement a Shift also
at the y axis (north/south)? I need this to scroll/shift in this directions too.

 
Mighty7:

It works like a charme but to have it complete, is it possible to implement a Shift also
at the y axis (north/south)? I need this to scroll/shift in this directions too.

OK. I will do it.

 
Mighty7:

It works like a charme but to have it complete, is it possible to implement a Shift also
at the y axis (north/south)? I need this to scroll/shift in this directions too.

done

ver 1.43

Файлы:
 
Nikolai Semko :

getan

siehe 1.43

Absolutely brilliant. Thank you very much.

Edit: x=-1,y=0 is not shifting, so it's not working correctly. 

 
Mighty7:

Absolutely brilliant. Thank you very much.

Edit: x=-1,y=0 is not shifting, so it's not working correctly. 

Спасибо. Исправил.

Файлы:
iCanvas.mqh  52 kb
 
Nikolai Semko:

Спасибо. Исправил.

I have to say thanks. Now it's perfect. Top work.

 
Mighty7:

I have to say thanks. Now it's perfect. Top work.

Can you please answer 1 last question? What is faster, shifting left/right or shifting up/down? Thanks again.

Причина обращения: