odin-blend2d

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

bl_sample_3.cpp (721B)


      1 #include <blend2d.h>
      2 #include <stdio.h>
      3 
      4 int main() {
      5   BLImage img(480, 480, BL_FORMAT_PRGB32);
      6   BLContext ctx(img);
      7 
      8   ctx.clear_all();
      9 
     10   // Read an image from file.
     11   BLImage texture;
     12   BLResult err = texture.read_from_file("Leaves.jpeg");
     13 
     14   // Handle a possible error.
     15   if (err != BL_SUCCESS) {
     16     printf("Failed to load a texture (err=%u)\n", err);
     17     return 1;
     18   }
     19 
     20   // Create a pattern and use it to fill a rounded-rect.
     21   // By default a repeat extend mode is used, but it can
     22   // be configured to use more extend modes
     23   BLPattern pattern(texture);
     24   ctx.fill_round_rect(
     25     BLRoundRect(40.0, 40.0, 400.0, 400.0, 45.5),
     26     pattern);
     27 
     28   ctx.end();
     29 
     30   img.write_to_file("bl_sample_3.png");
     31   return 0;
     32 }