odin-blend2d

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

bl_sample_4.cpp (682B)


      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   if (err != BL_SUCCESS) {
     15     printf("Failed to load a texture (err=%u)\n", err);
     16     return 1;
     17   }
     18 
     19   // Rotate by 45 degrees about a point at [240, 240].
     20   ctx.rotate(0.785398, 240.0, 240.0);
     21 
     22   // Create a pattern and use it to fill a round rect.
     23   BLPattern pattern(texture);
     24   ctx.fill_round_rect(
     25     BLRoundRect(50.0, 50.0, 380.0, 380.0, 80.5),
     26     pattern);
     27 
     28   ctx.end();
     29 
     30   img.write_to_file("bl_sample_4.png");
     31   return 0;
     32 }