Libraries: Easy Canvas - page 15

 
Nikolai Semko #:

If literally on a rectangular object, then no.
The canvas is also an object.
You can only "transform" a canvas object into a rectangle object by programming its contents to move and scale.
Visually, it can look exactly like a rectangular object with small squares in the corners to control it. But only a few programmers in this community will be able to implement this, including me.

If we are talking about the transformation of the internal contents of the rectangle. If we are talking about a simple filled or empty rectangle, any programmer can do it.

Ok Nikolai, understood. Thank you very much!

 
Facundo Laje #:

Ok Nikolai, understood. Thank you very much!

No problem.

The latest version is 1.47 here: https://www.mql5.com/ru/code/22164

If you are interested in this topic, I would recommend you to see this Russian speaking thread with Google Translate:

https://www.mql5.com/ru/forum/227736

Files:
iCanvas_CB.mqh  57 kb
 

Good day, colleagues!

Why doesn't the code below work for me? For example, I wanted to draw circles over bars that have certain conditions.

void  OnTimer()

 {

    Canvas.Erase(0x00FFFFFF);

      for(int i = 0; i < 100 ; i++)

       {

        if(iClose(_Symbol, PERIOD_CURRENT, i + 1) > iClose(_Symbol, PERIOD_CURRENT, i + 2))

         {

          Canvas.Circle((int)_X(Canvas.Bar(i + 1)), (int)_Y(Canvas.Price(iClose(_Symbol, PERIOD_CURRENT, i + 1))), 5, 0x88ff9999);

         }

       }

  Canvas.Update();

 }


 
Petr Zharuk #:

Good time, colleagues!

Why doesn't the code below work for me? For example, I wanted to draw circles over bars that have certain conditions.

void  OnTimer()

 {

    Canvas.Erase(0x00FFFFFF);

      for(int i = 0; i < 100 ; i++)

       {

        if(iClose(_Symbol, PERIOD_CURRENT, i + 1) > iClose(_Symbol, PERIOD_CURRENT, i + 2))

         {

          Canvas.Circle((int)_X(Canvas.Bar(i + 1)), (int)_Y(Canvas.Price(iClose(_Symbol, PERIOD_CURRENT, i + 1))), 5, 0x88ff9999);

         }

       }

  Canvas.Update();

 }


At first glance I see only one problem. For the X coordinate it is necessary:
_X(double (i))
The function double Canvas. Bar(int x) returns the bar number at the x coordinate of the window
 
Petr Zharuk #:

Good time, colleagues!

Why doesn't the code below work for me? For example, I wanted to draw circles over bars that have certain conditions.

void  OnTimer()

 {

    Canvas.Erase(0x00FFFFFF);

      for(int i = 0; i < 100 ; i++)

       {

        if(iClose(_Symbol, PERIOD_CURRENT, i + 1) > iClose(_Symbol, PERIOD_CURRENT, i + 2))

         {

          Canvas.Circle((int)_X(Canvas.Bar(i + 1)), (int)_Y(Canvas.Price(iClose(_Symbol, PERIOD_CURRENT, i + 1))), 5, 0x88ff9999);

         }

       }

  Canvas.Update();

 }

I got to my computer:

void  OnTimer()
  {
   Canvas.Erase(0x00FFFFFF);
   for(int i = (int)W.Right_bar; i <= W.Left_bar ; i++)
     {
      if(iClose(_Symbol, _Period, i) > iClose(_Symbol, _Period, i + 1))
        {
         Canvas.FillCircle((int)_X((double)i), (int)_Y(iClose(_Symbol, _Period, i)), 5, 0x88ff9999);
        }
     }
   Canvas.Update();
  }



 
Nikolai Semko #:

got to the computer:



Cheers Nikolai!

Thank you.

 

Is there an implementation of how to place text with adhesion?

An analogue of Align or something. Or at least a function that gets the size of the text block.

 
Petr Zharuk #:

Is there an implementation of how to place text with adherence?

An analogue of Align or something. Or at least a function that gets the size of the text block.

https://www.mql5.com/en/docs/standardlibrary/canvasgraphics/ccanvas/ccanvastextsize

https://www.mql5.com/en/docs/standardlibrary/canvasgraphics/ccanvas/ccanvastextout

 

Nicholas, are there any developments or examples of interaction with interface elements written in Canvas?

For example, there are two buttons Canvas.Rectangle.

How to check if one of them is clicked except for the option of checking mouse and button coordinates?

 
Petr Zharuk #:

Nikolay, are there any developments or examples of interaction with interface elements written in Canva?

For example, there are two buttons Canvas.Rectangle.

How to check if one of them is clicked except for the option of checking mouse and button coordinates?

Not yet