odin-blend2d

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

bl_sample_7.cpp (823B)


      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   const char font_name[] = "ABeeZee-Regular.ttf";
      9   const char regular_text[] = "Hello Blend2D!";
     10   const char rotated_text[] = "Rotated Text";
     11 
     12   ctx.clear_all();
     13 
     14   // Load font-face and handle a possible error.
     15   BLFontFace face;
     16   BLResult result = face.create_from_file(font_name);
     17   if (result != BL_SUCCESS) {
     18     printf("Failed to load a font (err=%u)\n", result);
     19     return 1;
     20   }
     21 
     22   BLFont font;
     23   font.create_from_face(face, 50.0f);
     24 
     25   ctx.set_fill_style(BLRgba32(0xFFFFFFFF));
     26   ctx.fill_utf8_text(BLPoint(60, 80), font, regular_text);
     27 
     28   ctx.rotate(0.785398);
     29   ctx.fill_utf8_text(BLPoint(250, 80), font, rotated_text);
     30 
     31   ctx.end();
     32 
     33   img.write_to_file("bl_sample_7.png");
     34   return 0;
     35 }