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

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
24 Sep, 2024 12:32 AM
24 Sep, 2024 12:27 AM
13 Sep, 2024 12:07 AM
12 Sep, 2024 11:54 PM
07 Sep, 2024 05:16 AM