odin-blend2d

Odin bindings to Blend2D
Log | Files | Refs | README | LICENSE

bl_sample_1.cpp (763B)


      1 #include <blend2d.h>
      2 
      3 int main() {
      4   // Use constructor or `create()` function to
      5   // allocate a new image data of the required
      6   // format.
      7   BLImage img(480, 480, BL_FORMAT_PRGB32);
      8 
      9   // Attach a rendering context into `img`.
     10   BLContext ctx(img);
     11 
     12   // Clearing the image would make it transparent.
     13   ctx.clear_all();
     14 
     15   // Create a path having cubic curves.
     16   BLPath path;
     17   path.move_to(26, 31);
     18   path.cubic_to(642, 132, 587, -136, 25, 464);
     19   path.cubic_to(882, 404, 144, 267, 27, 31);
     20 
     21   // Fill a path with opaque white - 0xAARRGGBB.
     22   ctx.fill_path(path, BLRgba32(0xFFFFFFFF));
     23 
     24   // Detach the rendering context from `img`.
     25   ctx.end();
     26 
     27   // Let's use some built-in codecs provided by Blend2D.
     28   img.write_to_file("bl_sample_1.png");
     29 
     30   return 0;
     31 }