Discussion of article "Visualize this! MQL5 graphics library similar to 'plot' of R language" - page 5

 
Artyom Trishkin #:

All smoothing methods are highly dependent on line opacity. At about 50% opacity everything becomes unaliased and has artefacts.

Now there are artefacts even with fully opaque lines.

We were talking about trying to draw a fully opaque circle with smoothed edges (using Wu's algorithm) without losing smoothness.

This requires special methods of filling with smoothed edges.

 
Anatoli Kazharski #:

There are now artefacts even with completely opaque lines.

It was about trying to draw a fully opaque circle with smoothed edges (using Wu's algorithm) without loss of smoothness.

This requires special methods of filling with smoothed edges.

I understand that you can't do it yourself?

 
Artyom Trishkin #:

I realise I can't do it on my own?

Why not? Give it a try! )

You can even solve the case you mentioned:

Forum on trading, automated trading systems and testing trading strategies

Discussion of the article "Visualise it! Graphical library in MQL5 as an analogue of plot from R"

Artyom Trishkin, 2023.07.31 12:39 AM

All smoothing methods strongly depend on line opacity. At about 50% opacity everything becomes non-smooth and has artefacts.

That is, drawing on a fully transparent canvas (CCanvas) can be done taking into account the bottom layer (chart and other objects) and it will be without artefacts.

But it seems rather crutchy and cumbersome. It is also unclear how much it will affect performance. I would still like the developers of the terminal to fix this bug.

 
Anatoli Kazharski #:

Why not? Give it a try! )

You can even solve the case you mentioned:

That is, rendering on a fully transparent canvas (CCanvas) can be done taking into account the bottom layer (chart and other objects) and it will be artefact-free.

But it seems rather crutchy and cumbersome. It is also unclear how much it will affect performance. I would still like the developers of the terminal to fix this bug.

I would send such a task (if not the developers, but forum members) to Nikolai @Nikolai Semko for solution ;)

 
Artyom Trishkin #:

I would send such a task (if not developers, but forum members) to Nikolai @Nikolai Semko for solving ;)

He works with only one canvas.

And I'm not ready to rewrite my graphics library to make everything work on one canvas.

Although it is interesting, but knowing how much time it may take, I can't decide to undertake such a challenge at the moment. I don't have as much time now as I used to.

 
Anatoli Kazharski #:

It only works with one canvas.

And I'm not ready to rewrite my graphics library to make everything work on one canvas.

Although it's interesting, but knowing how much time it might take I can't decide to undertake such a challenge at the moment. I don't have as much time now as I used to.

Well, it's an algorithm. What difference does it make - on one canvas or several?

 
Artyom Trishkin #:

Well, it's an algorithm. What difference does it make whether it's on one canvas or several?

We've discussed two problems:

1. If this is the one I was talking about originally, then an algorithmic solution would be sufficient for some cases.

2. If it's the one you mentioned, then a couple of functions won't do here. You need a scheme where all layers are stored in arrays. Each layer should be drawn taking into account what is drawn on the layers under it. In addition, all methods in the CCanvas class should be corrected. The colour of each pixel should be blended with the one below it, taking into account the transparency. Then there will be no artefacts (gaps, jagged edges, etc.). If you do it right, then you can implement translucency with blurring. All this is easy enough to implement on a single canvas. But when several canvases are used, it is much more difficult to implement.

 
Anatoli Kazharski #:

It only works with one canvas.

And I'm not ready to rewrite my graphics library to make everything work on one canvas.

Although it's interesting, but knowing how much time it might take I can't decide to undertake such a challenge at the moment. There isn't as much time now as there used to be.

I actually use multiple canvases ( usually no more than 4)
There is always a golden mean. One extreme is to paint all the statics and all the dynamics on one canvas, the other extreme is to paint all the objects as separate canvases.
It is important not to forget that if you have two canvases with transparency, overlapping each other, then still the CPU, (maybe in Win10-11 GPU, but I think still CPU), will mix each pixel even homogeneous (non-zero transparency) background.
Here we can borrow from JS the practice of caching the canvas or a part of it to improve performance.
As for antialiased circles, I've already published a variant of such a circle, which is ideal (in terms of performance) for circles with radius less than ~5 pixels. I think the function was called iDot(), and was in the 3DStars code. It is very primitive and short (about 10 lines of code). For larger radius circles, it is far from optimal in terms of performance. For larger radii, the high-performance function is already over 100 lines of code.
Yes, after years of establishing new neural connections in the brain on canvas, I can now make a library on canvas at any level. There would be time and motivation.
The Wu algorithm is considered obsolete.
 
Anatoli Kazharski #:

We discussed two challenges:

1. If it is the one I was talking about originally, then for some cases an algorithmic solution would be sufficient.

2. If it is the one you mentioned, then a couple of functions will not do. You need a scheme where all layers are stored in arrays. Each layer should be drawn taking into account what is drawn on the layers under it. In addition, all methods in the CCanvas class should be corrected. The colour of each pixel should be blended with the one below it, taking into account the transparency. Then there will be no artefacts (gaps, jagged edges, etc.). If you do it right, then you can implement translucency with blurring. All this is easy enough to implement on a single canvas. But when several canvases are used, it is much more difficult to implement.

I thought I was only talking about the smoothing algorithm. Without regard to overlaying transparent canvases on each other. Although... If you superimpose them, new problems will surely appear. That's why I referred to Nikolay - you see, he's got all neural connections for a long time, and his brain is probably already thinking by itself, taking into account all possible problems with the canvas )

 
Artyom Trishkin #:

I thought I was just talking about the smoothing algorithm. With no reference to overlaying transparent canvases on top of each other. Although... If you superimpose them, new problems will surely pop up. That's why I referred to Nikolay - you see, he's got all neural connections for a long time, and his brain is probably already thinking by itself taking into account all possible problems with the canvas).

Artem, these are really not trivial tasks that require new neural connections. For example, in SVG there is such a concept as viewBox. I've already watched a lot of videos about how it works, read a lot of documentation, written a lot of code, and still sometimes I get stumped. I still don't have the necessary neural connections, even though it seemed several times that I had figured it all out.