VuoModuleMetadata({
					  "title" : "Make Random List",
					  "keywords" : [ "uncorrelated", "arbitrary", "aleatoric", "chance", "pseudorandom",
							"prng", "rng", "arc4random", "uniform", "distribution", "white" ],
					  "version" : "1.0.0",
					  "genericTypes" : {
						  "VuoGenericType1" : {
							  "defaultType" : "VuoReal",
							  "compatibleTypes" : [ "VuoInteger", "VuoReal", "VuoPoint2d", "VuoPoint3d", "VuoPoint4d" ]
						  }
					  },
					  "node" : {
						  "exampleCompositions" : [ "Scribble.vuo" ]
					  }
				  });


void nodeEvent
(
		VuoInputData(VuoGenericType1, {"defaults":{"VuoInteger":  0, "VuoReal":0., "VuoPoint2d":{"x":-1.,"y":-1.}, "VuoPoint3d":{"x":-1.,"y":-1.,"z":-1.}, "VuoPoint4d":{"x":-1.,"y":-1.,"z":-1.,"w":-1.}}}) minimum,
		VuoInputData(VuoGenericType1, {"defaults":{"VuoInteger":100, "VuoReal":1., "VuoPoint2d":{"x": 1.,"y": 1.}, "VuoPoint3d":{"x": 1.,"y": 1.,"z": 1.}, "VuoPoint4d":{"x": 1.,"y": 1.,"z": 1.,"w": 1.}}}) maximum,
		VuoInputData(VuoInteger, {"default":10, "suggestedMin":1}) count,
		VuoOutputData(VuoList_VuoGenericType1) list
)
{
	*list = VuoListCreate_VuoGenericType1();
	for (VuoInteger i = 0; i < count; ++i)
		VuoListAppendValue_VuoGenericType1(*list, VuoGenericType1_random(minimum,maximum));
}
Пример #2
0
 */

#include "node.h"

VuoModuleMetadata({
					 "title" : "Append Lists",
					 "keywords" : [ "concatenate", "combine", "join", "together", "merge" ],
					 "version" : "1.0.0",
					 "node" : {
						  "exampleCompositions" : [ "SpliceSquares.vuo" ]
					 }
				 });

void nodeEvent
(
		VuoInputData(VuoList_VuoGenericType1) list1,
		VuoInputData(VuoList_VuoGenericType1) list2,
		VuoOutputData(VuoList_VuoGenericType1) combinedList
)
{
	*combinedList = VuoListCreate_VuoGenericType1();

	unsigned long list1Count = VuoListGetCount_VuoGenericType1(list1);
	for (unsigned long i = 1; i <= list1Count; ++i)
		VuoListAppendValue_VuoGenericType1(*combinedList, VuoListGetValue_VuoGenericType1(list1, i));

	unsigned long list2Count = VuoListGetCount_VuoGenericType1(list2);
	for (unsigned long i = 1; i <= list2Count; ++i)
		VuoListAppendValue_VuoGenericType1(*combinedList, VuoListGetValue_VuoGenericType1(list2, i));
}
Пример #3
0
static int compare (const void * a, const void * b)
{
	sortable_pointValue *x = (sortable_pointValue*)a;
	sortable_pointValue *y = (sortable_pointValue*)b;

	return (x->value - y->value);
}

void nodeEvent
(
		VuoInputData(VuoList_VuoGenericType1) list,
		VuoInputData(VuoGenericType1, {"default":{"x":0, "y":0, "z":0, "w":0}}) point,
		VuoOutputData(VuoList_VuoGenericType1) sorted
)
{
	*sorted = VuoListCreate_VuoGenericType1();

	int count = VuoListGetCount_VuoGenericType1(list);

	sortable_pointValue pointValues[count];

	for(int i = 0; i < count; i++)
		pointValues[i] = (sortable_pointValue){i, fabs(VuoListGetValueAtIndex_VuoGenericType1(list, i+1).z - point.z)};

	qsort (pointValues, count, sizeof(sortable_pointValue), compare);

	for(int i = 0; i < count; i++)
		VuoListAppendValue_VuoGenericType1(*sorted, VuoListGetValueAtIndex_VuoGenericType1(list, pointValues[i].index+1) );
}