» slice
This site relies heavily on Javascript. You should enable it if you want the full experience. Learn more.

slice

Spreads and Slices

vvvv can simultaneously handle a large count of objects, either graphical or data, with very little effort by the user. This means that it is just as easy to do an operation on a single value or on a hundred, in the same sense it is as easy to draw one object as it is to draw a whole swarm of objects. This technique is called spreading. It is somehow similar to the concept of vectors, arrays or lists in other programming languages, but it lacks most of the overhead usually associated with these constructs.

Basically, any pin and any connection can hold any number of values. When you use the tool tip you will see only the first value of these. If the pin contains more values, you will notice a number in brackets called the SliceCount after the value:

Individual values in a spread are called slices. Spreads are always one-dimensional – just a list of individual slices. The number of slices in a spread is referred to as SliceCount. All data can be interpreted as a spread – normal values are just a special case of a spread with only one element.

A particular feature of vvvv is that render nodes are also spreadable: If you connect a spread to a render object, it will be drawn multiple times. This makes it very easy to program complex particle animations.

Connecting Pins with different slice counts

It is perfectly possible to connect pins with different slice counts:

In case the output contains fewer slices than the input, vvvv just repeats the values (left image). If the output contains more slices, the superfluous slices are ignored (middle image). In case the output contains only one slice, all slices of the input are the same (right image; basically a special case of the left image)

The same applies when using spreads of different counts as inputs of an operation:

The spread on the left contains more elements than the right input. For simple scalar operations (like +) the output spread count is defined to be the maximum of all inputs.

To be precise it’s not just the maximum of the input slice counts: There is a special rule to handle empty spreads gracefully: The exact rule is: “As long as none of the input slice counts is zero, it’s the maximum, otherwise its zero”.
Note that this is a purely arbitrary strategy: Other languages like APL or J just forbid that case, but we felt that’s its very important for playful exploration to have a smart solution for these cases. We discussed other strategies, like taking the least common multiple or taking the minimum, but taking the above mentioned maximum operation proved to be the strategy with the most fun, as it also allows for mixing one-slice spreads with longer spreads in a natural way.

Therefore internally the right input gets resized to contain also seven slices. This is done by repetition of the smaller spreads:

The same concept also applies to render nodes:

As the maximum of all input slice counts is eight, there are eight objects drawn. The Type input has only three inputs, so the three different shapes are repeated over the eight elements. The color spread has only one slice, so all objects get the same color. It’s very instructive to play with these kinds of setups, as it will tend to create very complex behaviours in a very simple way. This can be considered a good thing.

Spreads in the Inspector

The Inspector by default shows only the first slice of a pin. If you want to see all slices of one pin, click on the double arrow >> icon in the middle of the inspector. Then a new list with all slices of the selected pin appears on the right side.

If the pin is connected, all slices appear dark, as they can’t be edited.

If the pin is disconnected, all slices appear bright, and can be edited. Also the slice count edit field is enabled and allows setting the slice count of the pin.

anonymous user login

Shoutbox

~10min ago

u7angel: @mediadog, make it a forum question.

~12min ago

u7angel: @mediadog, tty renderer ?

~3h ago

microdee: however non-conductive objects are invisible for this so the pencil and the sticks in the video are still a mysteries

~3h ago

microdee: hey i just found a possible solution behind leap's black magic http://www.quora.com/Leap-Motion/What-is-the-technology-behind-Leap-Motion

~3h ago

mediadog: @u7agel: red node, no connections; can' drag&drop into patch either - 27.2

~7h ago

christosk: Thanx Elliot! UnixPath worked fine :-)

~8h ago

elliotwoods: or 'unix path' (for forward slash). also custom deliminators are accepted on other pins

~8h ago

elliotwoods: @christosk : check for 'dos path'

~8h ago

christosk: What's the node to use in order to separate elements inside a string by using slashes? Separate doesn't give a Slash enumeration.

~11h ago

metrowave: vvvv not loading, it says 'no DLLs were found in the waterfall procedure' to do with error at loading ippSP library. any ideas?