Update Portuguese translation
[gegl.git] / examples / simple-graph.py
blob3b155f8787674e837bea2b41e6b257f02433887c
1 #!/usr/bin/env python
3 from gi.repository import Gegl
4 import sys
6 if __name__ == '__main__':
7 Gegl.init(sys.argv)
9 ptn = Gegl.Node()
11 # Disable caching on all child nodes
12 ptn.set_property("cache-policy", Gegl.CachePolicy.NEVER)
14 # Create our background buffer. A gegl:color node would
15 # make more sense, we just use a buffer here as an example.
16 background_buffer = Gegl.Buffer.new("RGBA float", 246, -10, 276, 276)
17 white = Gegl.Color.new("#FFF")
18 background_buffer.set_color(background_buffer.get_extent(), white)
20 src = ptn.create_child("gegl:load")
21 src.set_property("path", "data/surfer.png")
23 crop = ptn.create_child("gegl:crop")
24 crop.set_property("x", 256)
25 crop.set_property("y", 0)
26 crop.set_property("width", 256)
27 crop.set_property("height", 256)
29 buffer_src = ptn.create_child("gegl:buffer-source")
30 buffer_src.set_property("buffer",background_buffer)
32 over = ptn.create_child("gegl:over")
34 dst = ptn.create_child("gegl:save")
35 dst.set_property("path", "cropped.png")
37 # The parent node is only for reference tracking, we need to
38 # connect the node's pads to actualy pass data between them.
39 buffer_src.connect_to("output", over, "input")
40 src.connect_to("output", crop, "input")
41 crop.connect_to("output", over, "aux")
42 over.connect_to("output", dst, "input")
44 # Will create "cropped.png" in the current directory
45 dst.process()