better random color generation
New-ish to Nodebox and trying to generate a random array of two colors. I've attached what I've come up with, but realize that there might (will) be more elegant answers to this. I've tried a few other routes, but haven't been able to make it work. And another thing with this is it doubles up geometry (i.e. when opened in illustrator, there's two of everything...)
Any help appreciated.
- randomtest.ndbx 3 KB
Comments are currently closed for this discussion. You can start a new one.
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
1 Posted by JamesWlf on 01 May, 2013 05:31 PM
Hi. I placed a divide node between your count node and repeat node to solve the duplicated geometry issu. I divided the quantity by two since what happened was that since every color counts as an element in the list, and you have two colors, you were getting twice the number of colors, and the number of ellypses would grow twofold to adapt to the number of elements in the color list.
I'm also new to NB3 and I wasn't able to figure out how to eliminate the color that would remain if your number of ellypses would be odd, as it actually is in your example. I had a few ideas but they were too complicated and think there must an easier solution for taking the decision to take an element out of the color list if it's size doesn't match the number of ellypses.
Support Staff 2 Posted by lucasnijs on 02 May, 2013 08:31 AM
Hi Chris,
Your solution is OK (as is any solution that works). Concerning your problem with double geometry: you count the number of points in your grid (51) and you repeat this number twice by connecting it to the amount of colors in your colorlist (=2). If ypu look at your repeat list (double click it) you will see there are 102 colors listed. Your shuffle node will off course keep this amount and will have two values for every point on your grid, hence doubling the vectors. To solve: make a pick node, attach the repeated list as the list and the count of the grid as the number to be picked, et voila: 51 picked colors you can send to the colorize node.
best,
Lucas
Support Staff 3 Posted by lucasnijs on 02 May, 2013 09:31 AM
Chris,
here is a solution that uses a subnetwork "circles". It is like a function that generates as many random red and black circles you need. It is getting fed by an amount of random numbers to change the seed of picking one of the colors, and by the points of the grid where you want the circles to appear. Have fun.
4 Posted by Chris on 02 May, 2013 01:11 PM
Lucas,
Many thanks! The subnetwork was what I was missing. Just getting back into NodeBox so the help is appreciated.
Chris.
Support Staff 5 Posted by lucasnijs on 20 May, 2013 10:04 AM
You're welcome!
lucasnijs closed this discussion on 20 May, 2013 10:04 AM.