Blame examples/hello-world-video.c

Packit Service 2781ba
#include <gegl.h>
Packit Service 2781ba
#include <glib/gprintf.h>
Packit Service 2781ba
Packit Service 2781ba
gint
Packit Service 2781ba
main (gint    argc,
Packit Service 2781ba
      gchar **argv)
Packit Service 2781ba
{
Packit Service 2781ba
  gegl_init (&argc, &argv);  /* initialize the GEGL library */
Packit Service 2781ba
Packit Service 2781ba
  {
Packit Service 2781ba
    /* instantiate a graph */
Packit Service 2781ba
    GeglNode *gegl = gegl_node_new ();
Packit Service 2781ba
Packit Service 2781ba
/*
Packit Service 2781ba
This is the graph we're going to construct:
Packit Service 2781ba
 
Packit Service 2781ba
.-----------.
Packit Service 2781ba
| ff-save   |
Packit Service 2781ba
`-----------'
Packit Service 2781ba
   |
Packit Service 2781ba
.-------.
Packit Service 2781ba
| layer |
Packit Service 2781ba
`-------'
Packit Service 2781ba
   |   \
Packit Service 2781ba
   |    \
Packit Service 2781ba
   |     \
Packit Service 2781ba
   |      |
Packit Service 2781ba
   |   .------.
Packit Service 2781ba
   |   | text |
Packit Service 2781ba
   |   `------'
Packit Service 2781ba
.------------------.
Packit Service 2781ba
| fractal-explorer |
Packit Service 2781ba
`------------------'
Packit Service 2781ba
Packit Service 2781ba
*/
Packit Service 2781ba
Packit Service 2781ba
    /*< The image nodes representing operations we want to perform */
Packit Service 2781ba
    GeglNode *display    = gegl_node_new_child (gegl,
Packit Service 2781ba
                                 "operation", "gegl:ff-save",
Packit Service 2781ba
                                 "path", "fractal-zoom.avi",
Packit Service 2781ba
                                 "bitrate", 1200000.0,
Packit Service 2781ba
                                 NULL);
Packit Service 2781ba
    GeglNode *layer      = gegl_node_new_child (gegl,
Packit Service 2781ba
                                 "operation", "gegl:layer",
Packit Service 2781ba
                                 "x", 2.0,
Packit Service 2781ba
                                 "y", 4.0,
Packit Service 2781ba
                                 NULL);
Packit Service 2781ba
    GeglNode *text       = gegl_node_new_child (gegl,
Packit Service 2781ba
                                 "operation", "gegl:text",
Packit Service 2781ba
                                 "size", 10.0,
Packit Service 2781ba
                                 "color", gegl_color_new ("rgb(1.0,1.0,1.0)"),
Packit Service 2781ba
                                 NULL);
Packit Service 2781ba
    GeglNode *mandelbrot = gegl_node_new_child (gegl,
Packit Service 2781ba
                                "operation", "gegl:fractal-explorer",
Packit Service 2781ba
                                "width", 640,
Packit Service 2781ba
                                "height", 480,
Packit Service 2781ba
                                NULL);
Packit Service 2781ba
Packit Service 2781ba
    gegl_node_link_many (mandelbrot, layer, display, NULL);
Packit Service 2781ba
    gegl_node_connect_to (text, "output",  layer, "aux");
Packit Service 2781ba
   
Packit Service 2781ba
    /* request that the save node is processed, all dependencies will
Packit Service 2781ba
     * be processed as well
Packit Service 2781ba
     */
Packit Service 2781ba
    {
Packit Service 2781ba
      gint frame;
Packit Service 2781ba
      gint frames = 100;
Packit Service 2781ba
Packit Service 2781ba
      for (frame=0; frame
Packit Service 2781ba
        {
Packit Service 2781ba
          gchar string[512];
Packit Service 2781ba
          gdouble t = frame * 1.0/frames;
Packit Service 2781ba
          gdouble cx = -1.76;
Packit Service 2781ba
          gdouble cy = 0.0;
Packit Service 2781ba
Packit Service 2781ba
#define INTERPOLATE(min,max) ((max)*(t)+(min)*(1.0-t))
Packit Service 2781ba
Packit Service 2781ba
          gdouble xmin = INTERPOLATE(  cx-0.02, cx-2.5);
Packit Service 2781ba
          gdouble ymin = INTERPOLATE(  cy-0.02, cy-2.5);
Packit Service 2781ba
          gdouble xmax = INTERPOLATE(  cx+0.02, cx+2.5);
Packit Service 2781ba
          gdouble ymax = INTERPOLATE(  cy+0.02, cy+2.5);
Packit Service 2781ba
Packit Service 2781ba
          if (xmin<-3.0)
Packit Service 2781ba
            xmin=-3.0;
Packit Service 2781ba
          if (ymin<-3.0)
Packit Service 2781ba
            ymin=-3.0;
Packit Service 2781ba
Packit Service 2781ba
          gegl_node_set (mandelbrot, "xmin", xmin,
Packit Service 2781ba
                                     "ymin", ymin,
Packit Service 2781ba
                                     "xmax", xmax,
Packit Service 2781ba
                                     "ymax", ymax,
Packit Service 2781ba
                                     NULL);
Packit Service 2781ba
          g_sprintf (string, "%1.3f,%1.3f %1.3f×%1.3f",
Packit Service 2781ba
            xmin, ymin, xmax-xmin, ymax-ymin);
Packit Service 2781ba
          gegl_node_set (text, "string", string, NULL);
Packit Service 2781ba
          gegl_node_process (display);
Packit Service 2781ba
          g_print ("%3.0f%%  \r", t * 100);
Packit Service 2781ba
        }
Packit Service 2781ba
    }
Packit Service 2781ba
    g_print ("      \r");
Packit Service 2781ba
Packit Service 2781ba
    /* free resources used by the graph and the nodes it owns */
Packit Service 2781ba
    g_object_unref (gegl);
Packit Service 2781ba
  }
Packit Service 2781ba
Packit Service 2781ba
  /* free resources globally used by GEGL */
Packit Service 2781ba
  gegl_exit ();
Packit Service 2781ba
Packit Service 2781ba
  return 0;
Packit Service 2781ba
}