Blend2D is a next generation 2D vector graphics engine written in C++. It has been engineered from scratch to provide maximum performance of software based 2D rendering. It features a built-in JIT compiler that generates efficient pipelines at runtime and a completely new rasterizer that is both efficient and provides high quality anti-aliasing. The future of Blend2D is to offer asynchronous and multithreaded rendering for maximum performance.
Blend2D is written in C++, but provides both C and C++ APIs. Public functions use only C interface so each feature of the library is directly available to both C and C++ users. The primary goal of C API is to make it possible to use Blend2D from programming languages that can interface with C either natively or through FFI. The primary goal of C++ API is to make the library easy-to-use in C++ projects without the need of manual resource management. The C++ API is built on top of the C API and turns all objects that require initialization and finalization into smart objects that handle it automatically. The C++ API should be considered zero-cost and it even allows to interchange C and C++ objects if that's what is needed.
The following snippets provide an insight into the C and C++ APIs provided by Blend2D. Please note that both snippets were written to be comparable line-by-line and designed to be as narrow as possible.
Blend2D features a brand new rasterizer that was written from scratch to deliver superior performance. It's an analytic high-quality rasterizer, which is comparable to rasterizers used by AGG and FreeType. It's more efficient as it uses an innovative approach to index data that it builds during rasterization and that it scans during composition. It has a stable memory footprint and performs rasterization and composition in bands instead of using a typical scanline-based approach as used by most 2D libraries. The rasterizer is robust and excels in rendering text and complex vector art.
Blend2D provides similar paint styles as defined by SVG and HTML <canvas>, which include solid colors, gradients, and patterns. It uses a slot-based approach that allows to specify both fill and stroke styles separately. Gradients and patterns also support extend modes so it's possible to specify whether they should be padded, repeated, or reflected. Extend modes of patterns can be configured independently of X and Y.
Blend2D supports all Porter & Duff compositing operators and a wide range of blend modes defined by SVG, CSS, and PDF specifications. Composition and blending modes can be applied to any rendering operation including fills, strokes, and image blits.
After a successful alpha testing Blend2D will enter beta phase soon. At the moment Blend2D is undergoing a transition from C++ API to C API to make it possible to use the library from C and other programming languages (as initially the library was C++ only). This was an important decision that caused postponing the release date by around 2 months, but as a result Blend2D will get a very stable API.
Beta release will be the first open-source version of Blend2D released under ZLIB license.