color number of objects in grid.
I'm wondering if there is any way to color a certain number of objects placed in a grid.
E.g. If I create a grid of 100 rectangles (10x10 grid) can I make it so 63 of them are one color and the rest stay black?
How would I go about doing this if possible?
Any help will be much appreciated thanks.
|?||Show this help|
|ESC||Blurs the current field|
|r||Focus the comment reply box|
|^ + ↩||Submit the comment|
You can use
Command ⌘ instead of
Control ^ on Mac
1 Posted by andy.treichler on 01 Sep, 2017 04:10 PM
I think "comparison example in math tutorial" could be the solution to your question.
Support Staff 2 Posted by john on 01 Sep, 2017 05:07 PM
One simple way to do this is to slice your rectangles into two groups, color each group, then recombine.
Screenshot and sample attached. Happy NodeBoxing!
3 Posted by DesignerN3 on 01 Sep, 2017 09:39 PM
Thanks so much guys. The slice node was the key I was missing. I had been looking for something with that functionality but somehow missed it.
Support Staff 4 Posted by lucasnijs on 04 Sep, 2017 08:48 AM
Great solution from John again. Another way (there are many ways of doing this depending on your project goal), is to calculate the proportion of colors you need and then generate a list of colors to colorize the rectangles. It requires a few more nodes but the advantage is that if the proportion changes you do not have to change the numbers in two nodes, it is controlled by one number. Clever construction of your network allows for a network that can adapt to any number (or even any size of grid) that gets in. In particular handy for generative systems or data visualisation. The network in the sample I attach is not controlling if you go over 100 or under 0. The squares will be then all black in the former or all blue in the latter case. If a decimal number is put in the system automatically rounds the numbers, because the repeat node requires an integer.