Indexing a list; macros

A thumbwheel picks one frame of the list; three nodes that compute its range become one macro node.

Start from cartoon1b: iterate over a file list (or your own network from the previous tutorial). Instead of playing all the frames, we want to choose one with a thumbwheel, whose range follows the length of the list.

A thumbwheel that indexes the list

  1. Delete the iterate node. Drag an Index node (Standard > Filter): connect Filelist's filelist to its data, and its data output to Read Image's filename.
  2. Drag a ThumbWheelInt (Standard > Input). Index's index input has a widget: right-click it and choose Unbind (show the port), then connect the ThumbWheelInt's value to it. Turning the wheel now shows another frame.
  3. The largest index is the length of the list minus one. A len node (Standard > Python) gives the length: connect Filelist to its in1.
  4. Subtract one with an Op2 node (Standard > Filter, operator sub), whose second operand comes from an eval node (Standard > Input) that evaluates 1. Connect len to Op2's data1, eval to its data2, and Op2's result to the ThumbWheelInt's maxi input.
  5. Right-click the thumbwheel and choose Options…: set its minimum to 0 (Vision's option panel). The same dialog sets its maximum, its step, and how much one turn changes it.
Filelist, len, eval, Op2, ThumbWheelInt, Index, Read Image, Scale and Show Image; ThumbWheelInt selected
The thumbwheel picks the frame. ThumbWheelInt is selected: its value and its mini and maxi inputs are in the parameter column.
Checkpoint cartoon2: a thumbwheel indexes the list

Make a macro

len, eval and Op2 together compute "the last index of a list", which would be useful elsewhere. Let's make them one node.

  1. Shift-click len, eval and Op2 to select the three of them.
  2. Right-click one of them and choose Group into a macro…; name it indexMax. The three nodes become one macro node. The connections that crossed the group's edge become its ports, named after the node and port they reach inside: an input from Filelist (len_in1) and an output to the ThumbWheelInt (Op2_result; in the tutorial's network, whose Op2 node is named sub, sub_result).
  3. Double-click indexMax to open it in a tab. Its inputs come out of the input Ports node on the left, its outputs go into the output Ports node on the right.
The inside of indexMax: input Ports, len, the eval node, sub, output Ports
Inside indexMax. Connecting a node to the new port of input Ports or output Ports adds a port to the macro.
The network with the indexMax macro node between Filelist and ThumbWheelInt
The network with its macro. The macro's name has a ▣ mark.
Checkpoint cartoon2b: the indexMax macro
In Vision you made an empty macro from the Edit menu, cut the three nodes, pasted them inside, and connected them to the macro's input and output nodes yourself. Group into a macro does all of that; Explode macro undoes it.

Keeping nodes; making an application

Vision could save a changed node, or a macro, to a user library from the node's menu, and turn a network into an application with a user panel holding the widgets that matter. Neither is ported: