better random color generation

chris's Avatar

chris

30 Apr, 2013 06:42 PM

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.

  1. 1 Posted by JamesWlf on 01 May, 2013 05:31 PM

    JamesWlf's Avatar

    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.

  2. Support Staff 2 Posted by lucasnijs on 02 May, 2013 08:31 AM

    lucasnijs's Avatar

    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

  3. Support Staff 3 Posted by lucasnijs on 02 May, 2013 09:31 AM

    lucasnijs's Avatar

    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. 4 Posted by Chris on 02 May, 2013 01:11 PM

    Chris's Avatar

    Lucas,

    Many thanks! The subnetwork was what I was missing. Just getting back into NodeBox so the help is appreciated.

    Chris.

  5. Support Staff 5 Posted by lucasnijs on 20 May, 2013 10:04 AM

    lucasnijs's Avatar

    You're welcome!

  6. lucasnijs closed this discussion on 20 May, 2013 10:04 AM.

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

Recent Discussions

22 Feb, 2024 05:51 AM
22 Feb, 2024 01:11 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
05 Jan, 2024 04:54 PM
04 Jan, 2024 11:49 PM