Graphics

 View Only
Expand all | Collapse all

Quad color change based on value of text input

  • 1.  Quad color change based on value of text input

    Posted 12-06-2018 14:41

    I am trying to have a quad change color based on the value of the text input from a data source. I would like to do this using Visual Logic. Attached is a basic example of what I am trying to accomplish. I would greatly appreciate any help.



  • 2.  RE: Quad color change based on value of text input

    Posted 12-06-2018 19:08

    I have this working with numbers from a field in DashBoard and color changes with number input live.


    #XPression


  • 3.  RE: Quad color change based on value of text input

    Posted 12-06-2018 20:17
    This works great! Thank you. I also want to incorporate a Zero value (showing a gray color) and negative numbers that are different shades of red. I tried working off of your VL map, but not sure how to do it. Any thoughts?
    #XPression


  • 4.  RE: Quad color change based on value of text input

    Posted 12-07-2018 21:03

    The best method to do this effectively would be by running a script on the quad and setting up your conditionals that way, but the visual logic is doable but you're going to end up with a relatively large VL tree.

    For starters I would duplicate the Quad in question so there are a total of 3. Quad_Pos, Quad_Neg, Quad_Zero or something like that with Quad_Zero already having your gray material applied.



    You can run preset values into the inputs, but you can also set the base values directly in the node (they can all stay zero since that's what's deciding the logic).

    From there you would basically duplicate the previous logic used to adjust the positive, but change the threshold values to negative, replace the materials that run into the input selector (while also offsetting it by 1) and making sure it feeds into Quad_Neg.

    What's happening is that it's running the logic for both the positive and negative but one is just hidden. It's fine if you have one element in the scene, but it can get really cumbersome if you need to start doing multiples quads on say a heatmap.


    #XPression


  • 5.  RE: Quad color change based on value of text input

    Posted 12-10-2018 14:26
    Scripting certainly could do this, I at one point had a simple script that did this but there was only greater than/less than 0 conditional but I don't know which project it's hiding in or if I even have it anymore. But it would just be a matter of building out more If statements.

    With Visual Logic, I imagine you'd start your Add node/input selector at the lowest value you would want and go from there. I think you would still have to do something about zero though using some sort of And node to test if the value equals zero before running the rest of the logic tree.

    #XPression


  • 6.  RE: Quad color change based on value of text input

    Posted 12-10-2018 21:13

    Using @jbober proposition, if steps between values are constant we can simplify the logic with something like :



    Following @mgoetz solution , this can be extended to negative (and zero) values :



    In this example values from -40 to 49 are taken into account

    To deal with negative index , an offset of 4 (i.e. -40/10 ) is used.
    To deal with specific value of zero , one is added to "input selector" 's index for values >0

    see project sample : TYT_step_colors_001.zip


    #XPression


  • 7.  RE: Quad color change based on value of text input

    Posted 12-11-2018 15:08
    Thank you all! I'm going to use your VL example amignon, but thank you everyone for your input.
    #XPression


  • 8.  RE: Quad color change based on value of text input

    Posted 12-11-2018 20:43
    One more question... is there a way to assign red 5 and green 5 colors to a number that is over 49 & under -40? (in your example, when a number is greater than the values, the quad turns transparent. I want to keep everything the same, but when a number exceeds the value to hold the highest green and red color)
    #XPression


  • 9.  RE: Quad color change based on value of text input

    Posted 12-12-2018 14:59

    use "greater than" , "small than" and "input selector" blocks just after your text to do that .

    for example with highest value :


    #XPression


  • 10.  RE: Quad color change based on value of text input

    Posted 12-13-2018 15:27

    So I made a few changes from the original example. My divider is now at 2.5 (based on the incoming data and the color changes I want) and I have 5 different shades of green and red. Here is an example of what my VL looks like now.

    Would your example replace the first part of the VL or would it be in addition to the blocks I already have? And where would the input selectors plug into?


    #XPression


  • 11.  RE: Quad color change based on value of text input

    Posted 12-13-2018 18:20
    the "input selector" output replace your "percent change 1" output
    #XPression


  • 12.  RE: Quad color change based on value of text input

    Posted 12-13-2018 19:27
    It works for my positive values, but can I tie in the negative values the same way using the same blocks?
    #XPression


  • 13.  RE: Quad color change based on value of text input

    Posted 12-13-2018 19:50
    to clarify, both positive and negatives work independently, but is there a way to have both work simultaneously?
    #XPression


  • 14.  RE: Quad color change based on value of text input

    Posted 12-19-2018 12:49

    amignon -
    Here is how I set up the VL for max values. The negatives work, but not the positives (anything over 12.5 turns the quad transparent). Do I have this set up incorrectly?


    #XPression


  • 15.  RE: Quad color change based on value of text input

    Posted 12-19-2018 16:21

    So like this? I'm still doing something wrong...


    #XPression


  • 16.  RE: Quad color change based on value of text input

    Posted 12-20-2018 14:12

    So I connected the '-12.5 value' and the second input selector like this

    and it still gives me a transparent box for anything over 12.5, but the negative values work beyond -12.5... Any thoughts? And thank you so much for spending this amount of time with my question.


    #XPression


  • 17.  RE: Quad color change based on value of text input

    Posted 12-20-2018 15:52
    I attached the HM Green 5 color to the #11 on the Input selector and it seems to be working... Does this make sense? I tested it with various numerical values and so far it is working. Again, thank you for all of your help.
    #XPression