Algorithm can be visualized as graphs where the operations are Nodes and the values flow between these nodes through Connections.
For example, the operation:
(6.0 ÷ 3.0) + (2.0 × 4.0)
can be visualized as this graph:
The number nodes [6.0] and [3.0] are connected as inputs of the division [÷] node.
The number nodes [2.0] and [4.0] are connected as inputs of the multiplication [×] node.
The results of the division and multiplication nodes are connected as inputs of the addition [+] node.
The final result of the node graph is the result of the addition [+] node.
In PixaFlux this operation can be defined with nodes and connections:
The Number nodes define the values (6.0, 3.0, 2.0, 4.0).
The Number Divide node divides the values returned as result from nodes [6.0] and [3.0].
The Number Multiply node multiplies the values returned as result from nodes [2.0] and [4.0].
The Number Add node adds the results from the Number Divide and Number Multiply nodes.
The final result from the graph is returned by the result output of the Number Add node.
The Connection between two Nodes represents a value that flows from the output of one node to the input of other node.
In the above image:
The Number Node defines the number 4.0 and returns it as a NUMBER value in the output number.
The Number Root Node receives as input the NUMBER value that was returned by the Number Node.
The Number Root Node executes a square root operation on the input value and returns the result in it's result ouput.
PixaFlux supports the following types of Node Values:
BOOLEAN. A boolean value. (true, false).
NUMBER. A real number value. (0.0, 3.0, -2.0, 5.4, 3.141592).
POINT. A 2D point or vector value ([0.0, 0.0], [1.0, -3.0], [2.4, 3.8]).
FRAME. A rectangle defined by a position and size. (pos:[0.0, 0.0]; size:[120.0, 100.5]).
RGBO. A red, greed, blue and opacity value. ().
IMAGE. An image value.
CURVES. A Bezier Splines container with multiple curves.
TEXTURE. A procedural texture definition.
PixaFlux includes an Attributes Node that allows artists to create common attributes for the project, and node Attributes can be exposed as Inputs of the node.
This way two or more nodes can be affected by the same attribute in a consistent way:
In this project:
The Attributes node defines a FRAME attribute which is returned by the node as the output frame.
The Constant node has the frame attribute exposed as input, and the Attributes node frame is connected to this input.
The Random Noise node has the frame attribute exposed as input, and the Attributes node frame is connected to this input.
The outputs of the Constant and Random Noise nodes are connected as inputs of the Blend node, which composes them over with a low opacity.
Editing the Attributes node frame attribute notifies the Constant and Random Noise nodes, which get the new FRAME from the Attributes node and update their image output. This way both nodes are guaranteed to always generate an image with the same frame, i.e. in the same position and with the same size.
This feature allows Attributes to be reused on the Node Graph and affect multiple nodes.
The Attributes node converts its attributes to Node Values. This is how they are converted:
Attribute Value Types to Node Value Types
The BOOLEAN attribute value is converted to a BOOLEAN node value.
The NUMBER attribute value is converted to a NUMBER node value.
The POINT attribute value is converted to a POINT node value.
The FRAME attribute value is converted to a FRAME node value.
The RGBO attribute value is converted to a RGBO node value.
The STRING attribute value is converted to a STRING node value.
The CHOICE attribute value is converted to a STRING node value.
You can add to a PixaFlux project as Attributes nodes as you need, but the names of the attributes need to be unique across the project.
To learn more about this feature please do the following tutorials
Node Graph projects are algorithms, and one of the main advantages of algorithms is that they can be reused.
PixaFlux projects can be saved to a PXF file and be reused in other projects using the Node Graph node.
All attributes defined in Attributes nodes are common attributes of the project.
The Inputs and Outputs of the project can be defined with the Input-Output (IO) nodes.
This project applies a two color border to an image, and it contains all the necessary nodes to be reused in other projects:
The Attributes node defines 3 attributes: The size of the borders and the colors of the two borders.
The Gradient node: Generate image input Image IO node.
The Image IO inside the Inputs Node Frame defines the input of the reusable node.
The Image IO inside the Ouputs Node Frame defines the output of the reusable node.
The nodes inside the Body Node Frame define the body of the custom node: The Border nodes. Their exposed attributes are feeded by the Attributes Nodes. Left Click on node to expose its attributes.
This project is saved in a file Double_Border.pxf.
This project has a Node Graph node that loads Double_Border.pxf. The Double Border node applies the two borders to the image with the border size and colors defined in the attributes of the Node Graph node.
When the Node Graph node loads a PixaFlux project it executes the following actions:
The Node Graph node finds all the Attributes nodes in the pxf file and displays them in its attributes panel.
In this example the size, and two border color attributes are displayed in the Node Graph Node attributes panel.
The Node Graph node finds all IO nodes that have no output connections and sets them as its outputs. The name of the output socket is set to the name of the IO node or the name of the output type if the name is not defined.
In this example the rightmost Image IO node has nothing connected to its output, so its set as an output of the Node Graph node.
The Node Graph node finds all IO nodes with connections to their outputs and sets them as its inputs. Any nodes connected to the input of these nodes will be ignored by the Node Graph node. The name of the input socket is set to the name of the IO node or the name of the input type if the name is not defined.
In this example the Gradient node is ignored by the Node Graph node and the leftmost Image IO node is set as an input of the Node Graph node.
IO nodes that have no connections are ignored by the Node Graph node.
Node Frames are ignored by the Node Graph node.
The Node Graph node includes an iterations attribute. This attribute controls the number of iterations the Node Graph is executed.
The IO nodes support the incremental modification of output values, which are then used as inputs for the next iteration.
The total number of iterations and the current iteration are provided to the custom project in a Node Iterations node.
This project is similar to the Double Border project but it has some modifications to support loops:
The Loop Iterations node provides the total number of iterations and the current iteration.
The Image IO nodes have been renamed to image.
When the Node Graph node loads a PixaFlux project it executes this actions to support loops:
The Node Graph node finds all the Loop Iteration nodes.
The Node Graph node finds all IO inputs and outputs with the same name and pairs them to support variables that need to be updated during the loop.
When the Node Graph node is executed:
The Node Graph node plugs the total number of iterations into the Loop Iterations iterations attribute, and the current iteration is plugged into the iteration attribute.
At the beginning of the loop the values of the inputs that are paired to an output are updated with the value of the output on the previous iteration.