Blend2D: 2D Vector Graphics Engine with Delphi bindings (maybe Laz binding?) lazarus / 39-Graphics ---------------------------------------------------------------------- Boleeman · 2025-02-27 13:52 Found an interesting program called Blend2D with Delphi bindings. Wondered if Lazarus bindings could possibly be made? Here is some info: Blend2D for Delphi: language bindings and framework for Blend2D https://github.com/neslib/DelphiBlend2D I see that the Delphi bindings version has Blend2D.Vcl.PaintBox.pas Blend2D is high-performance 2D vector graphics engine.  It was written from scratch with the goal to achieve the best possible software-based acceleration of 2D rendering. Blend2D provides a high-quality analytic rasterizer, a new stroking engine that uses curve offsetting instead of flattening, and a 2D pipeline generator that uses JIT compilation to generate optimal 2D pipelines at runtime. Blend2D can render rectangles, simple shapes, geometries composed of lines and Bézier curves, and text. The 2D pipeline supports pixel composition, opacity control, and styles such as solid colors, gradients, and images. DelphiBlend2D opens op Blend2D for Delphi developers. It provides header translations for the Blend2D C API, as well as an object oriented framework to make it easier to use. DelphiBlend2D currently supports Windows (32 and 64-bit). Support for macOS, iOS and Android is planned for future versions. The C version is here: https://blend2d.com/ https://github.com/blend2d/blend2d ---------------------------------------------------------------------- TRon · 2025-02-27 20:14 Quote from: Boleeman on February 27, 2025, 02:52:02 pmWondered if Lazarus bindings could possibly be made? Yes, no problem. At least not a problem for the API bindings (got that already working when applied a butcher-knife  ). The Blend2d unit that encapsulates the API into OOP objects/records however, that is something that the current FPC compiler (3.2.2) is not able to handle. There are simply  Delphi'isms used that are not (yet) supported. That requires some re-writing. To name a few things: - static class operators in records (Delphi seems to be more lenient); - Enumeration types that declare values that are previously defined inside the same enumeration type.; - Enumeration types not in ascending mode (though that usually works when every entry is assigned a value); - I have no idea which generic TEnumerator was used for the Delphi version or which one to use for FPC as a replacement; - properties returning a generic type. edit: Delphi Header is somewhat older as well (missing a few newer functions present in latest released library). ---------------------------------------------------------------------- Boleeman · 2025-02-28 08:37 Thanks TRon for looking into it. I was thinking of re-installing Delphi on a spare laptop and trying out the Delphi Blend2D bindings to see it working in Delphi. Looking at all the Blend2D bindings, there were also JavaScript bindings and Python bindings. Maybe there may be a way to side step the bindings somehow by using Python4Delphi and use the Blend2D python binding. or JavaScript web-browser solution (There was a Fiddle for that had a really simple JavaScript Blend2D example) I was really impressed with Tomxe as he has some really good skills in binding c++ coded programs to Lazarus. I was going to "play around with his Github codes" to see how he did it and try to get some more experience with binding C++ with Lazarus. Anyhow, I was going to experiment a bit. ---------------------------------------------------------------------- cdbc · 2025-02-28 08:56 Hi Doesn't C++ binding involve 'flattening' to C api, before we (fpc) can use them, due to C++ mangling?!? Regards Benny ---------------------------------------------------------------------- Boleeman · 2025-02-28 09:09 What I have found is that usually there are other alternative Lazarus methods to get around barriers in Delphi codes. Just got to find an alternative "WORKING" Lazarus solution. Anyhow, I will "play around" and investigate. ---------------------------------------------------------------------- TRon · 2025-02-28 10:10 Quote from: cdbc on February 28, 2025, 09:56:13 amDoesn't C++ binding involve 'flattening' to C api, before we (fpc) can use them, due to C++ mangling?!? Yes but we are in luck. The library, written in C++ has already provided a flattended C API. The Delphi project provides bindings for the flattended C-API but also tries to provide an OOP implementation to mimic the original C++ by using the C-API binding. As long as using the flattened C-API you should be good to go (unfortunately most examples are C++). ---------------------------------------------------------------------- TRon · 2025-03-02 23:21 To give a taste I've attached the Pascal version of bl_sample_capi (as per current trunk of blend2d, e.g. not Delphi binding repo). Compiling the Delphi API binding unit with mode delphi or objfpc should do the trick (and ofc you need the blend2d library itself) (* see edit) Besides the already mentioned incompatibilities wrt Blend2d.pas unit (which requires a rewrite for FPC) a lot of stuff is missing from the Blend2D.Api.pas unit (it has been over 5 years since the last update of the Delphi bindings so no surprise there). I do not have the ambition to translate that what is missing, not even remotely (it is simply too much to still be/have fun). edit: forgot to mention that is if you are on windows. For Linux(oid) platforms the api file needs to be edited to have the correct shared library name and in case not installing the library, the environment variable LD_LIBRARY_PATH needs to be expanded to contain the location of the shared library prior to executing the compiled example. ---------------------------------------------------------------------- Boleeman · 2025-03-05 08:53 Thank you TRon for that the Pascal version of bl_sample_capi . I have been busy chopping down trees where I live in the Aussie heat to replace an old wooden fence , so sorry for replying a bit late. ---------------------------------------------------------------------- ArtProg2D · 2025-11-22 14:53 Sorry for raising an old topic. Is there an executable file with benchmarks somewhere?