Discussing the article: "Creating a Cairo-Inspired Graphics Library for MetaTrader 5 (Part 3): Edges and the First Filled Shape"
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 3): Edges and the First Filled Shape.
Part 3 implements a scanline rasterizer in pure MQL5. We convert path segments into top‑down edges, sweep each row, sort crossings, and apply the non‑zero winding rule to decide which pixels are inside. The result is a single Fill(path, color, buffer, w, h) routine that draws rectangles, stars, glyphs, or 2000‑edge shapes without per‑shape code, ready to integrate into your MQL5 projects.
Every shape in this part's demo goes through that call and no other. There are six shapes in the first row alone, plus a glyph, a fan of thin triangles and a 2000-edge flower. Compare it with Part 1, where a triangle and a circle needed two separate routines that shared not one line.
Getting there takes two pieces. The first is the edge: a segment rewritten into the form that answers the only question a scanline renderer ever asks. The second is the scanline sweep itself. It walks the buffer one row at a time, finds where that row crosses the outline, and decides which stretches are inside using the winding number.
Both ideas are older than most of the software you use. The scanline fill dates to the 1960s and has not needed replacing. The later parts—anti-aliasing, fill rules, clipping, and the active edge table—refine the four steps described today; they do not replace them.
Three things this version does badly, all of them on purpose, and all of them stated again where they happen in the code:
None of those are shortcuts to apologize for. Each is a separate idea. Mixing all of them into one article is exactly what makes a rasterizer feel like magic instead of a mechanism.
Author: Sandro Begashvili