Libraries: Easy Canvas - page 19

 

After using your code I would like to suggest a few improvements. The maths functions overlap in name with mine - perhaps I should rename them. Also your macros are cancelling the definition at the end, which could cause problems in my code if I use the same definitions. One last thing - it would be good to strip the definition before declaring OnChartEvent, this will eliminate the redefinition warning (if the function was already defined before your file was attached).

//+------------------------------------------------------------------+
int MyCeil (const double x) {
   return (x-(int)x>0)?(int)x+1:(int)x;
}
//+------------------------------------------------------------------+
int MyRound(const double x) {
   return (int)(x+((x>0)?0.5:-0.5));
}
//+------------------------------------------------------------------+
int MyFloor(const double x) {
   return (x>0)?(int)x:((int)x-x>0)?(int)x-1:(int)x;
}
#define  Ceil  MyCeil
#define  Round  MyRound
#define  Floor  MyFloor

...........

//+------------------------------------------------------------------+
#undef OnChartEvent
#define OnChartEvent SetOnChart(int x) {OnChart=true;  OnZ=false;}\
void MyChartEvent

#undef  Ceil
#undef  Round
#undef  Floor
#undef _Font
 
hini OnChartEvent, this will eliminate the redefinition warning (if the function was already defined before your file was attached).
This library was created 7 years ago before my 5 years of education as a software engineer. I would write this library very differently now. At the very least I would use the namespace.
What you are asking I cannot do, as it would break a lot of existing code of mine and other people who use this library.
Try to start using namespace at your place.

 
Nikolai Semko #:
This library was created 7 years ago before my 5 years of education as a software engineer. I would write this library very differently now. At the very least I would use the namespace.
I can't do what you are asking, as it would break a lot of existing code of mine and other people who use this library.
Try to start using namespace at your place.

100500 programmers will thank you sincerely before going to bed if you make a quality Easy Canvas 2 library.

I need it very much, but I don't have enough knowledge to make it myself....
 
Vladimir Pastushak #:

100500 programmers will thank you sincerely before going to bed if you make a quality Easy Canvas 2 library.

I need it very much, but I don't have enough knowledge to make it myself....

Vladimir, Renat said recently that they will implement Blend2D in the terminal and in the editor.
And it means that this library will already become a rudiment. The main thing is not to turn their intention into a long construction.

Blend2D
Blend2D
  • blend2d.com
2D Vector Graphics Engine
 
Vladimir Pastushak #:

100500 programmers will thank you sincerely before going to bed if you make a quality Easy Canvas 2 library.

I need it very much, but I don't have enough knowledge to make it myself....

And collect at least $1 from these 100500 programmers, then Nikolay will probably do it. Meanwhile it sounds like this: "Nikolay, you work on a new bibliography, and then we will thank you!" ))

A quality bibliography for graphics is expensive. For example, one author wrote a lot of articles about such a case. And where is this bibliography? It is working through a stump, that's why it is not popular....

 
Nikolai Semko #:

This is done to control multiple subwindows and multiple instances of iCanvas. After all, windows can be added and removed in the process of the indicator work.
For example, it is necessary for this indicator:

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

The object is created practically first, which leads to the fact that if more objects were created afterwards, they overlap the library object.

 
Vladimir Pastushak #:

The object is created almost first, which means that if more objects are created afterwards, they overlap the library object.

Yeah. That's the way it should be. What's the problem?
If you need to change the Z-index, you need to recreate objects in the right sequence
 
Nikolai Semko #:
Yeah. That's the way it should be. What's the problem?
If you need to change the Z-index, you need to recreate the objects in the right sequence

Thank you, I thought about it afterwards.....