[gegl] Add a python example that uses the Node API
- From: Daniel Sabo <daniels src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gegl] Add a python example that uses the Node API
- Date: Tue, 4 Jun 2013 11:59:34 +0000 (UTC)
commit 91cd71a27b2cce29f3fcda00518e13eae6586108
Author: Daniel Sabo <DanielSabo gmail com>
Date: Tue Jun 4 04:55:11 2013 -0700
Add a python example that uses the Node API
examples/simple-graph.py | 47 ++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 47 insertions(+), 0 deletions(-)
---
diff --git a/examples/simple-graph.py b/examples/simple-graph.py
new file mode 100755
index 0000000..13c3658
--- /dev/null
+++ b/examples/simple-graph.py
@@ -0,0 +1,47 @@
+#!/usr/bin/env python
+
+from gi.repository import Gegl
+from gi.repository import GObject
+
+if __name__ == '__main__':
+ Gegl.init(0,"")
+
+ ptn = Gegl.Node()
+
+ # Disable caching on all child nodes
+ GObject.Object.set_property(ptn, "dont-cache", True)
+
+
+ # Create our background buffer. A gegl:color node would
+ # make more sense, we just use a buffer here as an example.
+ background_buffer = Gegl.Buffer.new("RGBA float", 246, -10, 276, 276)
+ white = Gegl.Color.new("#FFF")
+ background_buffer.set_color(background_buffer.get_extent(), white)
+
+ src = ptn.create_child("gegl:load")
+ src.set_property("path", "data/surfer.png")
+
+ crop = ptn.create_child("gegl:crop")
+ crop.set_property("x", 256)
+ crop.set_property("y", 0)
+ crop.set_property("width", 256)
+ crop.set_property("height", 256)
+
+ buffer_src = ptn.create_child("gegl:buffer-source")
+ buffer_src.set_property("buffer",background_buffer)
+
+ over = ptn.create_child("gegl:over")
+
+ dst = ptn.create_child("gegl:save")
+ dst.set_property("path", "cropped.png")
+
+ # The parent node is only for reference tracking, we need to
+ # connect the node's pads to actualy pass data between them.
+ buffer_src.connect_to("output", over, "input")
+ src.connect_to("output", crop, "input")
+ crop.connect_to("output", over, "aux")
+ over.connect_to("output", dst, "input")
+
+ # Will create "cropped.png" in the current directory
+ dst.process()
+
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]