odin-blend2d

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

sample_3.odin (1062B)


      1 
      2 package main
      3 
      4 import blend2d "../binding"
      5 
      6 main :: proc() {
      7 
      8 	img: blend2d.ImageCore
      9 
     10 	blend2d.image_init(&img)
     11 	blend2d.image_create(&img, 480, 480, .PRGB32)
     12 
     13 	ctx: blend2d.ContextCore
     14 	ctx_cfg: blend2d.ContextCreateInfo
     15 
     16 	blend2d.context_init(&ctx)
     17 	blend2d.context_begin(&ctx, &img, &ctx_cfg)
     18 	blend2d.context_clear_all(&ctx)
     19 
     20 	texture: blend2d.ImageCore
     21 	blend2d.image_init(&texture)
     22 	blend2d.image_read_from_file(&texture, "blend2d/testing/resources/Leaves.jpeg", nil)
     23 
     24 	pattern: blend2d.PatternCore
     25 	blend2d.pattern_init(&pattern)
     26 	blend2d.pattern_set_image(&pattern, &texture, nil)
     27 
     28 	rect := blend2d.RoundRect {
     29 		x  = 40,
     30 		y  = 40,
     31 		w  = 400,
     32 		h  = 400,
     33 		rx = 45.5,
     34 		ry = 45.5,
     35 	}
     36 
     37 	blend2d.context_fill_geometry_ext(&ctx, .ROUND_RECT, &rect, cast(^blend2d.Unknown)(&pattern))
     38 	blend2d.context_end(&ctx)
     39 
     40 	codec: blend2d.ImageCodecCore
     41 	codecs: blend2d.ArrayCore
     42 	blend2d.image_codec_array_init_built_in_codecs(&codecs)
     43 	blend2d.image_codec_init_by_name(&codec, "PNG", len("PNG"), nil)
     44 	blend2d.image_write_to_file(&img, "sample_3.png", &codec)
     45 }
     46