gegl r2303 - in trunk: . examples



Author: ok
Date: Sat May 17 16:55:55 2008
New Revision: 2303
URL: http://svn.gnome.org/viewvc/gegl?rev=2303&view=rev

Log:
* examples/2gegl.c: tool to convert image files to native GeglBuffers.
* examples/clock.c: test/toy to write the current timestamp
continously to a geglbuffer.
* examples/gegl-paint.c: modified default values of strokes.
* examples/multiplayer-paint.sh: added a launcher for multiplayer
paint, modify it to refer to a local image file.


Added:
   trunk/examples/2gegl.c
   trunk/examples/clock.c
   trunk/examples/multiplayer-paint.sh   (contents, props changed)
Modified:
   trunk/ChangeLog
   trunk/examples/gegl-paint.c

Added: trunk/examples/2gegl.c
==============================================================================
--- (empty file)
+++ trunk/examples/2gegl.c	Sat May 17 16:55:55 2008
@@ -0,0 +1,39 @@
+#include <glib.h>
+#include <gegl.h>
+
+gint
+main (gint    argc,
+      gchar **argv)
+{
+  GeglBuffer *buffer;
+  GeglNode   *gegl, *load_file, *save_file;
+
+  gtk_init (&argc, &argv);
+
+  gegl_init (&argc, &argv);
+
+
+  if (argv[1]==NULL ||
+      argv[2]==NULL)
+    {
+      g_print ("\nusage: %s in.png out.gegl\n\nCreates a GeglBuffer from an image file.\n\n", argv[0]);
+      exit (-1);
+    }
+
+  gegl = gegl_node_new ();
+  load_file = gegl_node_new_child (gegl,
+                              "operation", "load",
+                              "path", argv[1],
+                              NULL);
+  save_file = gegl_node_new_child (gegl,
+                                     "operation", "save-buffer",
+                                     "buffer", &buffer,
+                                     NULL);
+
+  gegl_node_link_many (load_file, save_file, NULL);
+  gegl_node_process (save_file);
+
+ 
+  gegl_buffer_save (buffer, argv[2], NULL);
+  return 0;
+}

Added: trunk/examples/clock.c
==============================================================================
--- (empty file)
+++ trunk/examples/clock.c	Sat May 17 16:55:55 2008
@@ -0,0 +1,91 @@
+#include <gegl.h>
+#include <glib/gprintf.h>
+
+#include <sys/time.h>
+#include <time.h>
+
+gint
+main (gint    argc,
+      gchar **argv)
+{
+  GeglNode   *gegl;   /* the gegl graph we're using as a node factor */
+  GeglNode   *display,
+             *text,
+             *layer,
+             *crop,
+             *shift,
+             *blank;
+
+  if (argv[1]==NULL)
+    {
+      g_print ("\nUsage: %s <GeglBuffer>\n"
+               "\n"
+               "Continously writes a timestamp to 0,0 in the buffer\n", argv[0]);
+      exit (-1);
+    }
+
+  gegl_init (&argc, &argv);  /* initialize the GEGL library */
+
+  gegl = gegl_node_new ();
+
+
+  blank      = gegl_node_new_child (gegl,
+                                    "operation", "color",
+                                    "value", gegl_color_new ("rgba(0.0,0.0,0.0,0.4)"),
+                                    NULL);
+
+  crop       = gegl_node_new_child (gegl,
+                                    "operation", "crop",
+                                    "x", 0.0,
+                                    "y", 0.0,
+                                    "width", 260.0,
+                                    "height", 22.0,
+                                    NULL);
+
+  layer      = gegl_node_new_child (gegl,
+                                    "operation", "layer",
+                                    NULL);
+
+  shift      = gegl_node_new_child (gegl,
+                                    "operation", "shift",
+                                    "x", 0.0,
+                                    "y", 0.0,
+                                    NULL);
+
+  text       = gegl_node_new_child (gegl,
+                                   "operation", "text",
+                                   "size", 20.0,
+                             /*      "color", gegl_color_new ("rgb(0.0,0.0,0.0)"),*/
+                                   NULL);
+  display    = gegl_node_new_child (gegl,
+                                    "operation", "composite-buffer",
+                                    "path", argv[1],
+                                    NULL);
+
+  gegl_node_link_many (blank, crop, layer, shift, display, NULL);
+  gegl_node_connect_to (text, "output", layer, "aux");
+  
+  /* request that the save node is processed, all dependencies will
+   * be processed as well
+   */
+  {
+    gint frame;
+    gint frames = 1024;
+    GTimeVal val;
+
+    for (frame=0; frame<frames; frame++)
+      {
+        gchar string[512];
+        struct timeval tv;
+
+        gettimeofday(&tv, NULL);
+        gegl_node_set (text, "string", ctime((void*)&tv), NULL);
+        gegl_node_process (display);
+        g_usleep (1000000);
+      }
+  }
+  /* free resources globally used by GEGL */
+  gegl_exit ();
+
+  return 0;
+}

Modified: trunk/examples/gegl-paint.c
==============================================================================
--- trunk/examples/gegl-paint.c	(original)
+++ trunk/examples/gegl-paint.c	Sat May 17 16:55:55 2008
@@ -24,8 +24,8 @@
 #include "../bin/gegl-view.c"
 #include "property-types/gegl-vector.h"
 
-#define HARDNESS    0.8
-#define LINEWIDTH  23.0
+#define HARDNESS     0.8
+#define LINEWIDTH   10.0
 
 GtkWidget *window;
 GtkWidget *view;

Added: trunk/examples/multiplayer-paint.sh
==============================================================================
--- (empty file)
+++ trunk/examples/multiplayer-paint.sh	Sat May 17 16:55:55 2008
@@ -0,0 +1,10 @@
+#!/bin/sh
+
+./2gegl data/car-stack.jpg test.gegl
+./clock test.gegl &
+./gegl-paint test.gegl &
+./gegl-paint test.gegl
+
+killall -9 clock gegl-paint
+
+



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]