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

code snippets

Examples for declaring Pins using attributes

This is an Input Pin of type bool (ie. 0 or 1) with a hint to the GUI that it should be operated as a Bang. And it is Single which means it is not spreadeable.

[Input("Reset", IsBang = true, IsSingle = true)]
ISpread<bool> FReset;

This is an Input Pin with minimun value 0.0 and maximum value 1.0. The Order attribute specifies the position of the pin in the node 0 will be left most 1 will be second pin from the left ...

[Input("Friction", MinValue = 0.0, MaxValue = 1.0, Order = 0)]
ISpread<double> FFriction;

This is an Input pin called My Input with Variable name FInput of type int with a default value of 2. Remember that a pin can always be reset to its default using Alt+Rightclick on the pin.

[Input("My Input", DefaultValue = 2)]
IDiffSpread<int> FInput;

Using IDiffSpread instead of ISpread allows you to check if the pins data has changed using the .IsChanged property:

if (FInput.IsChanged) 
//do something 

This is a pin of type Vector2D whose x and y default values are both 0.0

[Input("Input", DefaultValues = new double[] {0.0, 0.0}]
ISpread<Vector2D> FInput;

PinGroup vs. BinSize

A PinGroup likge eg. used in Cons (Spreads) that allows you to specify the number of inputs via a configuration pin in the Inspektor can be specified like:

[Input("Input", IsPinGroup = true)]
ISpread<ISpread<double>> FInput;

If you do the same but leave out the IsPinGroup = true instead of the configuration pin that sets the pincount you'll get a BinSize pin:

ISpread<ISpread<double>> FInput;

More info: pin attributes

Dealing with SliceCount

Examples for getting and setting SliceCount:

Get the Maximum spread count of any of the Input pins and set it to the Output pin.

FOutput.SliceCount = SpreadMax;

Get the SliceCount of a certain Pin


Get the maximum SliceCount of two Pins.

var count = FInput1.CombineWith(FInput);
FOutput.SliceCount = count;

Get the minimum SliceCount from two pins.

var count = Math.Min(FInput.SliceCount, FInput1.SliceCount);
FOutput.SliceCount = count;


Playing with List&AssignFrom

List are a convinient way to play with dynamic spreads ,you can add , remove ,insert and much more...
you need to add this : using System.Collections.Generic; to your code .
There are many examples on the net you will find some nice ones in dotnetperls

// we make a new list and called it myList 
      List<int> myList = new List<int>();

We make some logic with it

// If the Pin Add is Bang the spread from the Input Pin gets in .
            if (FAdd[0])
              myList.Clear();// We clear the List here to start all over otherwise we,ll add a new spread each time we bang .
             // Here we get the spread from Input Pin in 
             // so loop as many times as the size of the spread to get it
            for (int i = 0; i < FInput.SliceCount; i++)
            //here we add some more logic ,If spread contains the value in the filter pin 
            //we remove all occurances in the spread of this value.
            if (myList.Contains(FFilter[0]))
            myList.RemoveAll(item => item == FFilter[0]);
            // some more we want to add a value on top of the list and at the end 
                // To the begginig of the List
                //Note this is the whole list so if you add again another one will be place
            myList.Add(111);// to the end of the List
// We clear the List if the Reset Pin is bang 
            if (FReset[0])

We Assing the List to our Output Pin

// we set the SliceCount of our Output pin to be the same as size of the List .
            FOutput.SliceCount = myList.Count;
            //and Assign the data from our List to the Output Pin .

This is the Patch&Code of it .

Note : In most occasions will be more effective to use already in ISpread(T) Extension Methods instead of creating new list like

FInput.Add(FInput[i]) or FInput.RemoveAll(item => item == FFilter[0]);

instead of creating the new List and do

myList.RemoveAll(item => item == FFilter[0]);

anonymous user login


~4h ago

joreg: reminder: this wednesday #vvvv meetup nr 8 in #berlin 8-berlin-vvvv-meetup

~1d ago

metrowave: Yes, thanks for the streamming.

~3d ago

Hadasi: ...classic

~3d ago

Hadasi: @welove the videos are still up there https://www.twitch.tv/wirmachenbunt/videos

~3d ago

welovemedia: Big thanks for the stream, will this stay online or be shared as a download for those who could not watch it live?

~3d ago

CeeYaa: Big THX for the daylong streaming - and amazing Project Insights https://www.twitch.tv/videos/412932722

~4d ago

u7angel: twitch livestream vvvv gamma

~5d ago

u7angel: @domj, sure

~5d ago

domj: @u7angel: nice! How about the talk later at 7?

~5d ago

u7angel: vvvv-gamma-presentation will be streamed on twitch, starts 2pm, channel name is vvvv gamma