Discussing the article: "Creating a Cairo-Inspired Graphics Library for MetaTrader 5 (Part 2): Points, Contours and the Path"
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Check out the new article: Creating a Cairo-Inspired Graphics Library for MetaTrader 5 (Part 2): Points, Contours and the Path.
This second part adds the geometry layer to a Cairo‑inspired graphics library for MetaTrader 5. It defines a path of double‑precision points grouped into contours, records open/closed intent, and stores vertices in a flat array with start indices. We implement MoveTo, LineTo, Close, provide basic shape helpers, and include a demo that visualizes the built geometry for inspection and reuse.
The staircase in Part 1 resulted from the binary rendering approach and the loss of sub-pixel information.
In the first panel, the edge lies exactly on a pixel boundary, so integer storage loses no information. In the second, the original position is 10.35, but integer storage removes the fractional part. As a result, the renderer receives the same stored coordinate in both cases and cannot distinguish between them. The third panel preserves the coordinate as a double, allowing column 10 to retain its fractional coverage and the rendered edge to match the geometry.
This has two practical consequences:
Even a complex icon may contain thousands of points, while the geometry remains small compared with the pixel buffer used to render the panel.
Curves provide another reason to preserve floating-point coordinates. When a curve is flattened into straight segments, its vertices land at fractional positions (eg, 12.3719…, not 12). If the point type could not store those values, curves would be quantized to whole pixels before drawing, and anti-aliasing would not be able to compensate.
Author: Sandro Begashvili