Forum Replies Created

  • Ivan Zornic

    May 5, 2017 at 3:17 pm in reply to: Link to another color and adjust it

    Hi there,
    I know that this tread is bit old but I couldn’t find inverse function: RgbToHsl().
    I have created JS copy of function provided here:
    https://wiki.secondlife.com/wiki/Color_conversion_scripts#RGB_to_HSL
    but it returns some strange values.

    Any help will be appreciated.

    function RgbToHsl(rgb){

    var r = rgb[0] / 255;
    var g = rgb[1] / 255;
    var b = rgb[2] / 255;

    var h;
    var s;
    var l;

    var max;
    var min;

    // Looking for the max value among r, g and b
    if (r > g && r > b) max= r;
    else if (g > b) max = g;
    else max = b;

    // Looking for the min value among r, g and b
    if (r < g && r < b) min = r;
    else if (g < b) min = g;
    else min = b;

    l = (max + min) / 2;

    if (max == min){
    h = 0.0;
    s = 0.0;
    }else{

    var d = max - min;

    if (l > 0.5) s = d / (2 - max - min);
    else s = d / (max + min);

    if (max == r) {
    if (g < b) h = (g - b) / d + 6;
    else h = (g - b) / d;
    }
    else if (max == g)
    h = (b - r) / d + 2;
    else
    h = (r - g) / d + 4;

    h /= 6;
    }

    return [h, s, l];
    }

  • Ivan Zornic

    December 14, 2016 at 7:58 pm in reply to: Using a script to add an expression to a layer?

    Hi,
    I have trouble with expression that returns value. I did not find any way to return value and assign it to a var.

    I want to use sempleImage() expression from script and store resulting value to var. How can I do that?

    Thanks in advance,
    Ivan

  • Thanks for fast reply.
    I’m trying to call this function from script with no result.
    There is no error, script just stop on point where sampleImage() is called. Returns nothing and does not execute any code below.

    Is there any reference to this function? Where can I see what all 4 parameters are. First two are clear, but other two are not.

    Sorry for my ignorance, I am new to all this.

  • sampleImage() is what I’m looking for, but I can’t call this function from script file???

    Is there any way to do that?

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy