Mix Node

john's Avatar

john

02 Jan, 2024 08:09 PM

Continuing the cavalcade of new nodes...

The mix node!

Mix is an alternative to the heavily used combine node. Combine takes up to 7 lists and spits out all of list 1, then all of list 2, etc.

Mix, in contrast, produces a mix across all the input lists. So it will spit out the first item of list 1, then the first item of list 2, etc. and will continue until all input lists are exhausted. If some of the lists have fewer items than others, it will, in the usual Nodebox way, start repeating those shorter lists until the longest list is exhausted.

Suppose, for example, you want create an alternating list of light and dark colors. You can feed one list of light colors into the mix node's list1 port, and another list of dark colors into its list2 port. If you input 3 of each kind, you will get light1, dark1, light2, dark2, light3, dark3.
If you only give it 2 dark colors, the dark list will start to repeat until you have pairs with all 3 light colors: light1, dark1, light2, dark2, light3, dark1.

The attached demo shows an example. I have four lists:

  • 3 triangles in 3 colors
  • 4 squares in 4 colors
  • 5 pentagons in 5 colors
  • 6 hexagons in 6 colors

On the left I feed them into a combine node and it outputs the four lists in order. On the right I feed them into a mix node and it mixes them together until there are six complete sets of four types. Once the triangles are used up, they start to repeat, and so on.

That's it! Enjoy!

Reply to this discussion

Internal reply

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

Attaching KB article:

»

Already uploaded files

  • Mix_Node_Screenshot.png 650 KB
  • mix_node.ndbx.zip 34.7 KB

Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac

Recent Discussions

03 Mar, 2024 04:34 AM
23 Feb, 2024 07:39 PM
23 Feb, 2024 10:02 AM
22 Feb, 2024 05:51 AM
21 Feb, 2024 05:27 PM

 

21 Feb, 2024 04:49 PM
16 Feb, 2024 05:24 PM
06 Feb, 2024 04:45 AM
19 Jan, 2024 09:50 AM
13 Jan, 2024 03:47 AM
05 Jan, 2024 05:10 PM