We add the missing pieces: an affine transform and a context layer for the Cairo-style engine in MQL5. The six-number matrix is applied as paths are built, turning user coordinates into pixels and enabling reusable widgets by translation, scale, and rotation. CCairoContext stores transform, clip, source, and fill rule, with Save/Restore to manage state safely.
After nine parts the engine is complete as a set of parts. It flattens curves, sweeps scanlines, computes coverage, blends premultiplied colors, fills under either winding rule, paints with solids and gradients, and stops at a clip that can be a rectangle or any path at all.
Two things are missing, and they are the two things a 2D library of this kind generally ends up with. The first is a transform — a rule that converts the coordinates a caller writes into the pixels the rasterizer draws, so that a widget can be written once at the origin and placed anywhere. The second is a context — one object that remembers the transform, the clip, the source color and the fill rule, and that can push a copy of all four aside and get them back.
This part builds both. No pixel-level code changes: the rasterizer, the paints, the clip and the surface are untouched. Most of what follows is bookkeeping that used to live in the caller, moved to where it belongs — with one genuine change of meaning underneath it, which is that a stored vertex stops being the number the caller wrote and becomes the pixel it lands on.
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
Check out the new article: Creating a Cairo-Inspired Graphics Library for MetaTrader 5 (Part 10): Transforms and the Graphics Context.
After nine parts the engine is complete as a set of parts. It flattens curves, sweeps scanlines, computes coverage, blends premultiplied colors, fills under either winding rule, paints with solids and gradients, and stops at a clip that can be a rectangle or any path at all.
Two things are missing, and they are the two things a 2D library of this kind generally ends up with. The first is a transform — a rule that converts the coordinates a caller writes into the pixels the rasterizer draws, so that a widget can be written once at the origin and placed anywhere. The second is a context — one object that remembers the transform, the clip, the source color and the fill rule, and that can push a copy of all four aside and get them back.
This part builds both. No pixel-level code changes: the rasterizer, the paints, the clip and the surface are untouched. Most of what follows is bookkeeping that used to live in the caller, moved to where it belongs — with one genuine change of meaning underneath it, which is that a stored vertex stops being the number the caller wrote and becomes the pixel it lands on.
Author: Sandro Begashvili