odin-blend2d

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

bl_sample_2.cpp (821B)


      1 #include <blend2d.h>
      2 
      3 int main() {
      4   BLImage img(480, 480, BL_FORMAT_PRGB32);
      5   BLContext ctx(img);
      6 
      7   ctx.clear_all();
      8 
      9   // Coordinates can be specified now or changed
     10   // later via BLGradient accessors.
     11   BLGradient linear(BLLinearGradientValues(0, 0, 0, 480));
     12 
     13   // Color stops can be added in any order.
     14   linear.add_stop(0.0, BLRgba32(0xFFFFFFFF));
     15   linear.add_stop(0.5, BLRgba32(0xFF5FAFDF));
     16   linear.add_stop(1.0, BLRgba32(0xFF2F5FDF));
     17 
     18   // `set_fill_style()` can be used for both colors
     19   // and styles. Alternatively, a color or style
     20   // can be passed explicitly to a render function.
     21   ctx.set_fill_style(linear);
     22 
     23   // Rounded rect will be filled with the linear
     24   // gradient.
     25   ctx.fill_round_rect(40.0, 40.0, 400.0, 400.0, 45.5);
     26   ctx.end();
     27 
     28   img.write_to_file("bl_sample_2.png");
     29   return 0;
     30 }