BLEND 2D

next generation 2d vector graphics engine

WHAT IS BLEND 2D

Blend2D is a next generation 2D vector graphics engine written in C++. It features a built-in JIT compiler that generates high performance 2D pipelines at runtime, which are much faster than static pipelines used in today's 2D engines. Dynamic pipeline construction is the main difference between Blend2D and other 2D engines, and guarantees the highest possible throughtput by taking advantage of CPU extensions detected at runtime. Blend2D provides also a deferred and asynchronous rendering, which makes it seamless to integrate with event-based environments such as node.js and next generation UI toolkits.

EASY TO BIND

Blend2D is written in C++, but it doesn't use C++ exceptions for error handling, which makes it very easy to be used from different programming languages. A b2d.js library, which provides Blend2D bindings for node.js and V8 engine, is developed together with Blend2D. It is built on top of NJS (NeutralJS), which provides a foundation to build bindings for multiple JS engines and environments. b2d.js has been designed to be as close as possible to the C++ side, although it takes advantage of recent javascript features such as properties and typed arrays. At the moment b2d.js supports node.js v4+ and can be also used in projects that use pure V8 (i.e. without node.js).

NJS was developed together with b2d.js as a result of many breaking changes in V8 JavaScript engine. The future goals are to target multiple JS engines at a source code level and to minimize the impact of breaking changes of these JS engines on JS bindings build on top of NJS. Preliminary version of NJS is already available on github. A screencast showing basic features of b2d.js is available.

EASY TO USE

Both Blend2D and b2d.js libraries provide easy to understand and intuitive APIs. A minimal and self-explanatory source code comparision between C++ and JavaScript usage is shown below.

C++ API


    #include <b2d/b2d.h>
    
    b2d::Image render() {
      b2d::Image img(256, 256, b2d::Image::kFormatPRGB32);
      b2d::Context2D ctx(img);
    
      b2d::LinearGradient g(0, 0, 256, 256);
      g.addStop(0.0, b2d::Argb32(0x00000000));
      g.addStop(1.0, b2d::Argb32(0xFFFFFFFF));
    
      ctx.setCompOp(b2d::Context2D::kCompOpSrc);
      ctx.setFillStyle(g);
      ctx.fillAll();
    
      ctx.end();
      return img;
    }
    

JavaScript API


    var b2d = require("b2d");
    
    function render() {
      var img = new b2d.Image(256, 256, "prgb32");
      var ctx = new b2d.Context2D(img);
    
      var g = new b2d.LinearGradient(0, 0, 256, 256)
        .addStop(0.0, "#00000000")
        .addStop(1.0, "#FFFFFFFF");
    
      ctx.compOp = "src";
      ctx.fillStyle = g;
      ctx.fillAll();
    
      ctx.end();
      return img;
    }
    

ANALYTIC RASTERIZER

Blend2D uses a highly improved version of a rasterizer used by FreeType and AntiGrain. The rasterizer calculates anti-aliased edges by using an analytic approach (i.e. it doesn't use super-sampling). The rasterizer has been primarily designed for text rendering and can render either high quality vector art or text. The original rasterizer has been rewritten completely to improve performance, to decrease memory footprint, and to be more robust. The latest phase of rasterization is SIMD optimized.

PAINTING STYLES

Blend2D is a feature rich library that aims to support rendering content defined by SVG, PDF, and other standards. It supports filling and stroking of simple shapes and graphics paths, and allows to change various rendering properties like transformation, fill rule, and stroke options. Blend2D supports various source styles applicable to all painting operations. Graphics paths can be defined by using line segments and both quadratic and cubic B├ęzier curves.

COMPOSITING & BLENDING

Blend2D supports all Porter&Duff operators designed for composition of digital images. In addition, it also supports wide range of blending operators defined by SVG, CSS, and PDF specifications. Compositing and blending operators can be applied to any rendering operation, including fills, strokes, and image blits.

COMING SOON

Blend2D is developed privately at the moment, but once ready the source code will be released under a ZLIB license. There is no schedule, but the estimated alpha release for testing purposes is February 2017. However, the date is flexible and can be changed accordingly to the project status.

The first part of Blend2D project called B2dPipe is already available on github. It can be used independently of Blend2D and can bring JIT acceleration to any 2D rendering engine.

See Blend's roadmap for more details about all planned and finalized features.

SUPPORT BLEND

Blend2D started as a personal spare-time project to experiment with JIT compilation of 2D pipelines. However, it's not an experiment anymore and the author is working on releasing a fully working library that can act as a replacement of libraries used today. The library will be released under ZLIB license making it a free technology for everyone.

Blend2D is not backed by any company at the moment and really needs your support. Be first!

Contact us if you have any question regarding the support of the project.