#include <gegl.h>

void main() {
    GeglNode *graph, *save, *source;
    GeglBuffer *buffer;
    GeglRectangle extent;

    babl_init();
    gegl_init(0, NULL);

    const Babl *format = babl_format_new(babl_model ("R'aG'aB'aA"), babl_type ("u16"),
                             babl_component("R'a"), babl_component("G'a"), babl_component("B'a"), babl_component("A"),
                             NULL);

    const int orig_size = 100;
    const int new_size = 500;

    gegl_rectangle_set(&extent, 0, 0, orig_size, orig_size);

    buffer = gegl_buffer_new(&extent, format);

    gegl_rectangle_set(&extent, 0, 0, new_size, new_size);
    gegl_buffer_set_extent(buffer, &extent);

    GeglColor *color = gegl_color_new("rgba(0.5,0.5,0.5,1.0)");
    gegl_color_set_rgba(color, 0.5, 0.0, 0.0, 1.0);
    gegl_buffer_set_color(buffer, &extent, color);

    graph = gegl_node_new();
    source = gegl_node_new_child(graph, "operation", "gegl:buffer-source", "buffer", buffer, NULL);
    save = gegl_node_new_child(graph, "operation", "gegl:png-save", "path", "test.png", NULL);
    gegl_node_link(source, save);

    gegl_node_process(save);
}

