Update Portuguese translation
[gegl.git] / examples / geglbuffer-clock.c
blobb90dd7fe71c14c4d3af6c6b9a805c0d014a869ac
1 #include <stdlib.h>
2 #include <gegl.h>
3 #include <glib/gprintf.h>
5 #include <sys/time.h>
6 #include <time.h>
8 gint
9 main (gint argc,
10 gchar **argv)
12 GeglNode *gegl; /* the gegl graph we're using as a node factor */
13 GeglBuffer *buffer;
14 GeglNode *display,
15 *text,
16 *layer,
17 *crop,
18 *shift,
19 *blank;
21 if (argv[1]==NULL)
23 g_print ("\nUsage: %s <GeglBuffer>\n"
24 "\n"
25 "Continously writes a timestamp to 0,0 in the buffer\n", argv[0]);
26 exit (-1);
29 gegl_init (&argc, &argv); /* initialize the GEGL library */
31 gegl = gegl_node_new ();
34 buffer = gegl_buffer_open (argv[1]);
36 blank = gegl_node_new_child (gegl,
37 "operation", "gegl:color",
38 "value", gegl_color_new ("rgba(0.0,0.0,0.0,0.4)"),
39 NULL);
41 crop = gegl_node_new_child (gegl,
42 "operation", "gegl:crop",
43 "x", 0.0,
44 "y", 0.0,
45 "width", 260.0,
46 "height", 22.0,
47 NULL);
49 layer = gegl_node_new_child (gegl,
50 "operation", "gegl:layer",
51 NULL);
53 shift = gegl_node_new_child (gegl,
54 "operation", "gegl:translate",
55 "x", 0.0,
56 "y", 0.0,
57 NULL);
59 text = gegl_node_new_child (gegl,
60 "operation", "gegl:text",
61 "size", 20.0,
62 "color", gegl_color_new ("rgb(1.0,1.0,1.0)"),
63 NULL);
64 display = gegl_node_new_child (gegl,
65 "operation", "gegl:write-buffer",
66 "buffer", buffer,
67 NULL);
69 gegl_node_link_many (blank, crop, layer, shift, display, NULL);
70 gegl_node_connect (text, "output", layer, "aux");
72 /* request that the save node is processed, all dependencies will
73 * be processed as well
76 gint frame;
77 gint frames = 1024;
79 for (frame=0; frame<frames; frame++)
81 struct timeval tv;
83 gettimeofday(&tv, NULL);
84 gegl_node_set (text, "string", ctime((void*)&tv), NULL);
85 gegl_node_process (display);
86 g_usleep (1000000);
89 /* free resources globally used by GEGL */
90 gegl_exit ();
92 return 0;