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

18 Nov, 2024 11:24 PM
18 Nov, 2024 09:01 PM
07 Nov, 2024 10:53 AM
02 Nov, 2024 11:22 AM
01 Nov, 2024 12:41 AM

 

01 Oct, 2024 07:59 AM
30 Sep, 2024 11:37 PM
30 Sep, 2024 11:11 AM
30 Sep, 2024 02:37 AM
28 Sep, 2024 10:33 AM
26 Sep, 2024 06:41 AM