Multiple ellipsis in different colors

Aricia's Avatar

Aricia

26 Dec, 2018 11:58 AM

Hi, I have multiple ellipses and I want to color all the ellipses with number 40, in red. I want to do the same thing for all the others.
Can anyone help me?
Thank you in advance.

  1. Support Staff 1 Posted by john on 27 Dec, 2018 07:24 PM

    john's Avatar

    Hi Aricia,

    The basic technique is to feed your list of ellipses into a colorize node and feed a list of colors into the fill port of that colorize node. If the two lists have the same number of items, the first color will go to the first ellipse, the second color to the second ellipse, and so forth.

    The trick, then, is to form that list of colors.

    Apparently you also have a list of numbers which you are placing next to each ellipse. If you wanted to color all ellipses associated with the number 40 red and all others, say, black you could use a switch node.

    Feed your list of numbers into a compare node to test whether each value is equal to 40. Feed that list of booleans into the the rightmost index port of the switch node; false will read as 0 and true will read as 1. Feed a black color into the first (false) node of the switch and red into the second (true).

    The result will be a list of colors, red when the ellipse number is 40, black otherwise. Feed that into your colorize node and you're done!

    You said you want to "do the same thing for all the others". I'm not sure what you meant by that. If you want to assign each value a different color across a spectrum, or across a finite set of colors, you will need to create a set of nodes (or a subnetwork) to convert each value into a color.

    The convert_range and hsb_color nodes are handy for this. Feed your list of values into the convert_range node to convert each one into a value along a range of the color spectrum and feed that into the hue port of the hsb_color node. Voila! A list of colors for your colorize node.

    I made a demo showing both methods (screenshot and file attached).

    Let me know if this helps. If you're still stuck please attach a zipped copy of your NodeBox network along with a description of how you want to assign the numbers to different colors and I will help you figure it out.

    Good luck!

    John

  2. 2 Posted by Aricia on 28 Dec, 2018 05:50 PM

    Aricia's Avatar

    Thank you John. This helped me a lot.

Reply to this discussion

Internal reply

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

Attaching KB article:

»

Already uploaded files

  • Screenshot_2018-12-26_at_12.57.29.png 160 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

24 Apr, 2019 02:11 AM
24 Apr, 2019 02:04 AM
10 Apr, 2019 10:43 AM
31 Mar, 2019 10:32 AM
24 Mar, 2019 08:45 PM

 

24 Mar, 2019 12:07 AM
23 Mar, 2019 09:00 PM
22 Mar, 2019 06:37 AM
17 Mar, 2019 10:13 PM
11 Mar, 2019 12:35 AM
04 Mar, 2019 03:36 AM