Change color with one slider

  1. 6 years ago

    Yugo

    9 Feb 2018 User since 2017
    Edited 6 years ago by Yugo

    I would change the color of object with one slider.

    It have to change the hue but I don't know how to do it ?

    Thank's you in advance.

    Gwendal

  2. marco

    16 Feb 2018 Administrator User since 2016

    Hi @Yugo you are right, there is no easy way right now.
    We'll probably have a solution in the next beta.

  3. marco

    8 Mar 2018 Administrator User since 2016

    Hi @Yugo starting from the next beta you'll be able to use the following code in the Changed event of the Slider control (assuming that you have a Slider1 and a View1 with a predefined background color set from the Inspector):

    // extract original color
    var color1 = View1.backgroundColor;
    
    // extract each component
    var h = value;
    var s = color1.saturation;
    var b = color1.brightness;
    var a = color1.alpha;
    
    // create and set the new color
    var color2 = Color.hsba(h,s,b,a);
    View1.backgroundColor = color2;

    In the current beta the Color.hsba function is missed.

or Sign Up to reply!