bl_sample_5.cpp (881B)
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 // First shape filled with a radial gradient. 10 // By default, SRC_OVER composition is used. 11 BLGradient radial( 12 BLRadialGradientValues(180, 180, 180, 180, 180)); 13 radial.add_stop(0.0, BLRgba32(0xFFFFFFFF)); 14 radial.add_stop(1.0, BLRgba32(0xFFFF6F3F)); 15 ctx.fill_circle(180, 180, 160, radial); 16 17 // Second shape filled with a linear gradient. 18 BLGradient linear( 19 BLLinearGradientValues(195, 195, 470, 470)); 20 linear.add_stop(0.0, BLRgba32(0xFFFFFFFF)); 21 linear.add_stop(1.0, BLRgba32(0xFF3F9FFF)); 22 23 // Use 'set_comp_op()' to change a composition operator. 24 ctx.set_comp_op(BL_COMP_OP_DIFFERENCE); 25 ctx.fill_round_rect( 26 BLRoundRect(195, 195, 270, 270, 25), linear); 27 28 ctx.end(); 29 30 img.write_to_file("bl_sample_5.png"); 31 return 0; 32 }