Node
Nodes are basic building blocks of a graph (program). There are various node types, each providing a specific basic functionality.
Composition
A node is composed of input ports, output ports, and controls. Ports accepts connections from edges, and control provides user interfaces for the node.
Port
Control
Behavior
A node’s behavior is determined by its type.
In many cases, nodes behaves like functions (Intuitively, nodes look just like functions). However, nodes can also serve as program structures, stateful objects, interactive user interface, or more. The behavior is defined by inheriting Node class and add custom logics using Python.
These are the common categories of nodes’ behavior:
Function
A node can inherently represent a multi-in multi-out function. Its input ports represent the function’s input, and the output ports represents the outputs. The function is evaluated once all input ports are data ready, and the outcome will be pushed to the output ports.
The function can be either pure or not. If needed, the node can store runtime-only state in its Python object dict and saveable state in its attributes.
Often, a large portion of node types in an extension would be just wrappers of functions provided by libraries, such as grapycal_numpy.SinNode.
Program Structure
The grapycal_builtin extension provides several nodes for program structure, including loops, function calls, portals, etc.. Their use is general regardless of the situation.
User Interface
These types of nodes let the user interact with the graph in the runtime. They are usually dedicated designed to optimize the interacting UX by abstracting out the gap between human and machine (Python). For example, the imagePasteNode reads an image file from the clipboard, convert it into a NumPy array, and output it to its port to let downstream nodes process the image data.