Class: Gegl::Node

Inherits:
Object
  • Object
show all
Defined in:
lib/gegl/node.rb

Instance Method Summary collapse

Constructor Details

#initialize(xmldata, path_root) ⇒ Gegl::Node

The Gegl::Node returned contains the graph described by the tree of stacks in the XML document. The tree is connected to the "output" pad of the returned node and thus can be used directly for processing. resolved in relation to.

Parameters:

  • xmldata (String)

    a \0 terminated string containing XML data to be parsed.

  • path_root (String)

    a file system path that relative paths in the XML will be

Instance Method Details

#<<(sink) ⇒ Object



27
28
29
30
# File 'lib/gegl/node.rb', line 27

def <<(sink)
  self.link(sink)
  self
end

#[](name) ⇒ Object



19
20
21
# File 'lib/gegl/node.rb', line 19

def [](name)
  get_property(name)
end

#[]=(name, value) ⇒ Object



23
24
25
# File 'lib/gegl/node.rb', line 23

def []=(name, value)
  set_property(name, value)
end

#add_child(child) ⇒ Gegl::Node

Make the GeglNode graph, take a reference on child. This reference will be dropped when the reference count on the graph reaches zero.

Parameters:

Returns:

#blit(scale, roi, format, destination_buf, rowstride, flags) ⇒ nil

Render a rectangular region from a node. width/height of the sampled region. coordinates after scale has been applied. left as NULL when forcing a rendering of a region. rowstride based on the width and bytes per pixel for the specified format. GEGL_BLIT_DIRTY. if cache is enabled, a cache will be set up for subsequent requests of image data from this node. By passing in GEGL_BLIT_DIRTY the function will return with the latest rendered results in the cache without regard to wheter the regions has been rendered or not.

Parameters:

  • scale (Float)

    the scale to render at 1.0 is default, other values changes the

  • roi (Gegl::Rectangle)

    the rectangle to render from the node, the coordinate system used is

  • format (Babl::Object)

    the Babl::Format desired.

  • destination_buf (GObject)

    a memory buffer large enough to contain the data, can be

  • rowstride (Integer)

    rowstride in bytes, or GEGL_AUTO_ROWSTRIDE to compute the

  • flags (Gegl::BlitFlags)

    an or'ed combination of GEGL_BLIT_DEFAULT, GEGL_BLIT_CACHE and

Returns:

  • (nil)

#blit_buffer(buffer, roi, level, abyss_policy) ⇒ nil

Render a rectangular region from a node to the given buffer.

Parameters:

  • buffer (Gegl::Buffer)

    the Gegl::Buffer to render to.

  • roi (Gegl::Rectangle)

    the rectangle to render.

  • level (Integer)

    mipmap level to render (0 for all)

  • abyss_policy (Gegl::AbyssPolicy)

Returns:

  • (nil)

#bounding_boxGegl::Rectangle

Returns the position and dimensions of a rectangle spanning the area defined by a node.

Returns:

  • (Gegl::Rectangle)

#cache_policyGegl::CachePolicy

Returns cache-policy.

Returns:

#cache_policy=(cache_policy) ⇒ Gegl::CachePolicy

Parameters:

Returns:

#childrenGLib::SList<Gegl::Node>

of the nodes contained within a GeglNode that is a subgraph. Use g_list_free () on the list when done.

Returns:

#connect(a_pad_name, b, b_pad_name) ⇒ Boolean

Makes a connection between the pads of two nodes, one pad should be a source pad the other a sink pad, order does not matter.

Returns TRUE if the connection was successfully made.

Parameters:

  • a_pad_name (String)

    and the pad of the node we want connected.

  • b (Gegl::Node)

    another node

  • b_pad_name (String)

    and its pad to be connected.

Returns:

  • (Boolean)

#connect_from(input_pad_name, source, output_pad_name) ⇒ Boolean

Makes a connection between the pads of two nodes.

Returns TRUE if the connection was successfully made.

Parameters:

  • input_pad_name (String)

    the name of the input pad we are connecting to

  • source (Gegl::Node)

    the node producing data we want to connect.

  • output_pad_name (String)

    the output pad we want to use on the source.

Returns:

  • (Boolean)

#connect_to(output_pad_name, sink, input_pad_name) ⇒ Boolean

Makes a connection between the pads of two nodes.

Returns TRUE if the connection was successfully made.

Parameters:

  • output_pad_name (String)

    the output pad we want to use on the source.

  • sink (Gegl::Node)

    the node we're connecting an input to

  • input_pad_name (String)

    the name of the input pad we are connecting to

Returns:

  • (Boolean)

#create_child(operation) ⇒ Gegl::Node

Creates a new processing node that performs the specified operation. All properties of the operation will have their default values. This is included as an addition to #gegl_node_new_child in the public API to have a non varargs entry point for bindings as well as sometimes simpler more readable code. Calling g_object_unref on a node will cause the node to be dropped by the parent. (You may also add additional references using g_object_ref/g_object_unref, but in general relying on the parents reference counting is easiest.)

Parameters:

  • operation (String)

    the type of node to create.

Returns:

  • (Gegl::Node)

    a newly created node. The node will be destroyed by the parent.

#detect(x, y) ⇒ Gegl::Node

Performs hit detection by returning the node providing data at a given coordinate pair. Currently operates only on bounding boxes and not pixel data. data ending up at x,y in the output of node.

Parameters:

  • x (Integer)

    x coordinate

  • y (Integer)

    y coordinate

Returns:

#disconnect(input_pad) ⇒ Boolean

Disconnects node connected to input_pad of node (if any).

Returns TRUE if a connection was broken.

Parameters:

  • input_pad (String)

    the input pad to disconnect.

Returns:

  • (Boolean)

#dont_cache=(dont_cache) ⇒ Boolean

Parameters:

  • dont_cache (Boolean)

Returns:

  • (Boolean)

    dont-cache

  • (Boolean)

    dont-cache

#dont_cache?Boolean

Returns dont-cache.

Returns:

  • (Boolean)

    dont-cache

#find_property(property_name) ⇒ GObject::ParamSpec

if no such property exists.

Parameters:

  • property_name (String)

    the name of the property to get a paramspec for.

Returns:

  • (GObject::ParamSpec)

    the GParamSpec of property or NULL

#gegl_operationGegl::Operation

Returns gegl-operation.

Returns:

#gegl_operation=(gegl_operation) ⇒ Gegl::Operation

Parameters:

Returns:

#get(first_property_name, array) ⇒ nil

Gets properties of a Gegl::Node.

double level; char *path;

gegl_node_get (png_save, "path", &path, NULL); gegl_node_get (threshold, "level", &level, NULL); name/value pairs, followed by NULL.

Parameters:

  • first_property_name (String)

    name of the first property to get.

  • array (Array)

    return location for the first property, followed optionally by more

Returns:

  • (nil)

#get_consumers(output_pad, nodes, pads) ⇒ Integer

Retrieve which pads on which nodes are connected to a named output_pad, and the number of connections. Both the location for the generated nodes array and pads array can be left as NULL. If they are non NULL both should be freed with g_free. The arrays are NULL terminated.

Returns the number of consumers connected to this output_pad.

Parameters:

  • output_pad (String)

    the output pad we want to know who uses.

  • nodes (Array<Gegl::Node>)

    optional return location for array of nodes.

  • pads (Array<String>)

    optional return location for array of pad names.

Returns:

  • (Integer)

#get_input_proxy(pad_name) ⇒ Gegl::Node

Proxies are used to route between nodes of a subgraph contained within a node. If no input proxy exists with this name a new one will be created.

Parameters:

  • pad_name (String)

    the name of the pad.

Returns:

  • (Gegl::Node)

    Returns an input proxy for the named pad.

#get_output_proxy(pad_name) ⇒ Gegl::Node

Proxies are used to route between nodes of a subgraph contained within a node. If no output proxy exists with this name a new one will be created.

Parameters:

  • pad_name (String)

    the name of the pad.

Returns:

  • (Gegl::Node)

    Returns a output proxy for the named pad.

#get_producer(input_pad_name, output_pad_name) ⇒ Gegl::Node

or NULL if no node is connected to the input_pad.

Parameters:

  • input_pad_name (String)

    the input pad we want to get the producer for

  • output_pad_name (String)

    optional pointer to a location where we can store a freshly allocated string with the name of the output pad.

Returns:

#get_property(property_name, value) ⇒ nil

This is mainly included for language bindings. Using #gegl_node_get is more convenient when programming in C.

Parameters:

  • property_name (String)

    the name of the property to get

  • value (GObject::Value)

    pointer to a GValue where the value of the property should be stored

Returns:

  • (nil)

#get_valist(first_property_name, args) ⇒ nil

valist version of #gegl_node_get name/value pairs, followed by NULL.

Parameters:

  • first_property_name (String)

    name of the first property to get.

  • args (Gegl::va_list)

    return location for the first property, followed optionally by more

Returns:

  • (nil)

#has_pad(pad_name) ⇒ Boolean

Returns TRUE if the node has a pad with the specified name

Parameters:

  • pad_name (String)

    the pad name we are looking for

Returns:

  • (Boolean)

#introspectable_get_bounding_boxGegl::Rectangle

Returns the position and dimensions of a rectangle spanning the area defined by a node.

Returns:

  • (Gegl::Rectangle)

    pointer a Gegl::Rectangle

#introspectable_get_property(property_name) ⇒ GObject::Value

Returns pointer to a GValue containing the value of the property.

Parameters:

  • property_name (String)

    the name of the property to get

Returns:

  • (GObject::Value)

    pointer to a GValue containing the value of the property

#is_graphBoolean

Returns:

  • (Boolean)

This is equivalent to gegl_node_connect (source, "output", sink, "input");

Parameters:

Returns:

  • (nil)

Synthetic sugar for linking a chain of nodes with "output"->"input". The list is NULL terminated.

Parameters:

  • first_sink (Gegl::Node)

    the first consumer of data.

  • array (Array)

    NULL, or optionally more consumers followed by NULL.

Returns:

  • (nil)

#list_input_padsArray<String>

If the node has any input pads this function returns a null terminated array of pad names, otherwise it returns NULL. The return value can be freed with g_strfreev().

Returns:

  • (Array<String>)

#list_output_padsArray<String>

If the node has any output pads this function returns a null terminated array of pad names, otherwise it returns NULL. The return value can be freed with g_strfreev().

Returns:

  • (Array<String>)

#nameString

Returns name.

Returns:

  • (String)

    name

#name=(name) ⇒ String

Parameters:

  • name (String)

Returns:

  • (String)

    name

  • (String)

    name

#new_child(first_property_name, array) ⇒ Gegl::Node

Creates a new processing node that performs the specified operation with a NULL terminated list of key/value pairs for initial parameter values configuring the operation. Usually the first pair should be "operation" and the type of operation to be associated. If no operation is provided the node doesn't have an initial operation and can be used to construct a subgraph with special middle-man routing nodes created with #gegl_node_get_output_proxy and #gegl_node_get_input_proxy. terminated with NULL. Calling g_object_unref on a node will cause the node to be dropped by the parent. (You may also add additional references using g_object_ref/g_object_unref, but in general relying on the parents reference counting is easiest.)

Parameters:

  • first_property_name (String)

    the first property name

  • array (Array)

    first property value, optionally followed by more key/value pairs,

Returns:

  • (Gegl::Node)

    A newly created Gegl::Node. The node will be destroyed by the parent.

#new_processor(rectangle) ⇒ Gegl::Processor

data.

Parameters:

  • rectangle (Gegl::Rectangle)

    the Gegl::Rectangle to work on or NULL to work on all available

Returns:

#operationString

Returns operation.

Returns:

  • (String)

    operation

#operation=(operation) ⇒ String

Parameters:

  • operation (String)

Returns:

  • (String)

    operation

  • (String)

    operation

#parentGegl::Node

Returns a GeglNode that keeps a reference on a child.

Returns:

#passthroughBoolean

Returns:

  • (Boolean)

#passthrough=(passthrough) ⇒ Boolean

Parameters:

  • passthrough (Boolean)

Returns:

  • (Boolean)

    passthrough

  • (Boolean)

    passthrough

#passthrough?Boolean

Returns passthrough.

Returns:

  • (Boolean)

    passthrough

#processnil

Render a composition. This can be used for instance on a node with a "png-save" operation to render all necessary data, and make it be written to file. This function wraps the usage of a GeglProcessor in a single blocking function call. If you need a non-blocking operation, then make a direct use of #gegl_processor_work. See Gegl::Processor.


GeglNode *gegl; GeglRectangle roi; GeglNode *png_save; unsigned char *buffer;

gegl = gegl_parse_xml (xml_data); roi = gegl_node_get_bounding_box (gegl);

create png_save from the graph, the parent/child relationship

only mean anything when it comes to memory management.

png_save = gegl_node_new_child (gegl, "operation", "gegl:png-save", "path", "output.png", NULL);

gegl_node_link (gegl, png_save); gegl_node_process (png_save);

buffer = malloc (roi.wroi.h4); gegl_node_blit (gegl, 1.0, &roi, babl_format("R'G'B'A u8"), buffer, GEGL_AUTO_ROWSTRIDE, GEGL_BLIT_DEFAULT);

Returns:

  • (nil)

#progress(progress, message) ⇒ nil

Parameters:

  • progress (Float)
  • message (String)

Returns:

  • (nil)

#remove_child(child) ⇒ Gegl::Node

Removes a child from a GeglNode. The reference previously held will be dropped so increase the reference count before removing when reparenting a child between two graphs.

Parameters:

Returns:

#set(first_property_name, array) ⇒ nil

Set properties on a node, possible properties to be set are the properties of the currently set operations as well as "name" and "operation". "operation" changes the current operations set for the node, "name" doesn't have any role internally in GEGL.

gegl_node_set (node, "brightness", -0.2, "contrast", 2.0, NULL); pairs, followed by NULL.

Parameters:

  • first_property_name (String)

    name of the first property to set

  • array (Array)

    value for the first property, followed optionally by more name/value

Returns:

  • (nil)

#set_enum_as_string(key, value) ⇒ nil

Parameters:

  • key (String)
  • value (String)

Returns:

  • (nil)

#set_property(property_name, value) ⇒ nil

This is mainly included for language bindings. Using #gegl_node_set is more convenient when programming in C.

Parameters:

  • property_name (String)

    the name of the property to set

  • value (GObject::Value)

    a GValue containing the value to be set in the property.

Returns:

  • (nil)

#set_valist(first_property_name, args) ⇒ nil

valist version of #gegl_node_set pairs, followed by NULL.

Parameters:

  • first_property_name (String)

    name of the first property to set

  • args (Gegl::va_list)

    value for the first property, followed optionally by more name/value

Returns:

  • (nil)

#time=(time) ⇒ nil

Sets the right value in animated properties of this node and all its dependendcies to be the specified time position.

Parameters:

  • time (Float)

    the time to set the properties which have keyfraes attached to

Returns:

  • (nil)

#to_xml(path_root) ⇒ String

Returns a freshly allocated \0 terminated string containing a XML serialization of the composition produced by a node (and thus also the nodes contributing data to the specified node). To export a gegl graph, connect the internal output node to an output proxy (see #gegl_node_get_output_proxy.) and use the proxy node as the basis for the serialization.

Parameters:

  • path_root (String)

    filesystem path to construct relative paths from.

Returns:

  • (String)

#to_xml_full(tail, path_root) ⇒ String

Returns a freshly allocated \0 terminated string containing a XML serialization of a segment of a graph from head to tail nodes. If tail is nil then this behaves just like #gegl_node_to_xml.

Parameters:

  • tail (Gegl::Node)

    a Gegl::Node

  • path_root (String)

    filesystem path to construct relative paths from.

Returns:

  • (String)

    XML serialization of a graph segment.

#use_opencl=(use_opencl) ⇒ Boolean

Parameters:

  • use_opencl (Boolean)

Returns:

  • (Boolean)

    use-opencl

  • (Boolean)

    use-opencl

#use_opencl?Boolean

Returns use-opencl.

Returns:

  • (Boolean)

    use-opencl