MQL5 Article · Preview

Creating a Cairo-Inspired Graphics Library for MetaTrader 5 (Part 1): Why the terminal needs its own 2D-renderer

Creating a Cairo-Inspired Graphics Library for MetaTrader 5 (Part 1): Why the terminal needs its own 2D-renderer

Introduction

Modern trading interfaces demand more than a grid of rectangles: rounded cards, rings and donuts, semi-transparent layers, smooth gradients, and arbitrary polygons are all standard UI ingredients. MQL5's native chart objects and even the standard CCanvas fall short: corners are square, fills are hard-edged, there is no true alpha in object background colors, geometry is whole-number only, and object counts can quickly affect responsiveness. At the same time, we want to stay entirely inside the terminal—no DLLs, no external tools—and present the result as a single chart object.

This series takes a different route. Instead of inventing a new architecture, we borrow the compact, battle-tested design of Cairo. Its core idea—keeping geometry (paths) separate from paint (sources), then resolving them through a per-pixel coverage mask before compositing onto the destination—provides a common foundation for smooth, scalable rendering across different shapes. Over the coming parts, we will implement that model in pure MQL5, one small, verifiable step at a time.

Part 1 establishes the rendering foundation: a single ARGB color representation and a reusable pixel surface bound to one OBJ_BITMAP_LABEL . From there, the later parts will change how pixels are selected and painted, while the mechanism that delivers them to the chart remains the same.

Continue reading on MQL5.com

The full article with complete source code is published on MQL5.com.

Read the full article