Discussing the article: "Creating a Cairo-Inspired Graphics Library for MetaTrader 5 (Part 4): Anti-Aliasing, Coverage and Compositing"
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 4): Anti-Aliasing, Coverage and Compositing.
The rasterizer now accumulates exact span coverage in X and sampled coverage in Y, and blends it via CairoBlendOver on straight ARGB. CairoAaSamples sets the number of vertical samples at runtime, making the cost nearly linear and localized to edges. Readers get smoother boundaries, correct compositing of translucent shapes, and controllable performance.
You draw shapes into a buffer and display them on a chart or UI, and everything looks fine — until diagonal edges and translucency reveal the limits. Any edge that is not exactly horizontal or vertical becomes a visible “staircase,” slender elements can vanish, and semi‑transparent fills can overwrite what was underneath instead of blending with it. These are not unrelated bugs: they come from the same root cause. The rasterizer in Part 3 answered the yes/no question “is the pixel center inside the shape?” (0 or 1). What we need is a quantitative answer: “what FRACTION of this pixel is inside?” — a coverage value between 0 and 1.
In this part we introduce that coverage number and use it in the compositing step so anti‑aliasing and alpha blending are handled by the same arithmetic. Coverage is computed exactly in X (interval subtraction) and approximated in Y by N horizontal sub‑scanlines (CairoAaSamples). The implementation changes are small and local: the rasterizer gains a coverage accumulator and AddSpan to credit fractional pixels, Color.mqh gains CairoBlendOver to multiply coverage into source alpha, and Config.mqh exposes the runtime quality dial. Measurable goals: straight edges should become smooth without a separate smoothing pass, translucent overlaps should produce correct compositing, and the CairoAaSamples setting should give a clear, measurable quality/speed tradeoff.
Author: Sandro Begashvili