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

06 Feb, 2025 01:37 AM
04 Feb, 2025 06:32 AM
04 Feb, 2025 05:04 AM
30 Jan, 2025 09:31 AM
30 Jan, 2025 09:08 AM

 

30 Jan, 2025 08:40 AM
24 Jan, 2025 07:50 AM
22 Jan, 2025 11:42 PM
21 Jan, 2025 09:43 AM
21 Jan, 2025 09:41 AM
21 Jan, 2025 09:36 AM