sssssssssss

01-24-2014, 03:15 PM

I didn't see anything for this but figured it wouldnt hurt to ask. Is there a way to set not only the rgb values of an image in showimg, but also hsl values?

View Full Version : Showimg HSL

sssssssssss

01-24-2014, 03:15 PM

I didn't see anything for this but figured it wouldnt hurt to ask. Is there a way to set not only the rgb values of an image in showimg, but also hsl values?

fowlplay4

01-24-2014, 03:37 PM

HSL can be used to find RGB, and vice versa.

So convert HSL to RGB:

http://stackoverflow.com/questions/2353211/hsl-to-rgb-color-conversion

I think someone wrote a function but you should be able to figure it out from that link.

So convert HSL to RGB:

http://stackoverflow.com/questions/2353211/hsl-to-rgb-color-conversion

I think someone wrote a function but you should be able to figure it out from that link.

sssssssssss

01-24-2014, 04:40 PM

Well, the rgb is ok and all, but trying to change an images colors the saturation is off with just rgb. Maybe im misunderstanding but if im getting the same values for rgb that I'm using now by translating the hsl to rgb its not going to solve that problem i dont think.

fowlplay4

01-24-2014, 05:25 PM

Well, the rgb is ok and all, but trying to change an images colors the saturation is off with just rgb. Maybe im misunderstanding but if im getting the same values for rgb that I'm using now by translating the hsl to rgb its not going to solve that problem i dont think.

HSL and RGB are the means to the same end.

Go into MSPaints color picker and play with it, you'll notice when you change any of the HSL values it changes the RGB and vice versa.

So when you change RGB you have to update the HSL values and vice versa.

HSL and RGB are the means to the same end.

Go into MSPaints color picker and play with it, you'll notice when you change any of the HSL values it changes the RGB and vice versa.

So when you change RGB you have to update the HSL values and vice versa.

sssssssssss

01-25-2014, 05:54 AM

I get what you're saying. What we're doing is we have an image that has 0 saturation. Then we're changing the RGB in graal to the colors we want specifically at specific times. The problem is because the original image has 0 saturation, when the new RGB is set in graal, the color is off. Converting HSL to RGB doesn't seem to help, because it's still RGB in the end, and the saturation is still to low. If we up the saturation, the color is still off. I guess maybe there should be a specific color where this wont happen for the original image? No idea what it should be though.

callimuc

01-25-2014, 03:05 PM

The problem is because the original image has 0 saturation, when the new RGB is set in graal, the color is off. Converting HSL to RGB doesn't seem to help, because it's still RGB in the end, and the saturation is still to low. If we up the saturation, the color is still off

how about making the saturation like 10 and add some sort of offset into your "hsl converter"?

how about making the saturation like 10 and add some sort of offset into your "hsl converter"?

sssssssssss

01-25-2014, 04:10 PM

That's what I was thinking of doing in a way. Basically just showing a palette for the colors, and then in script adjusting RGB to get as close as possible even tho its not the actual values on the palette.

I was just hoping there was an actual way to just adjust saturation instead of converting HSL-RGB. Thanks yall.

I was just hoping there was an actual way to just adjust saturation instead of converting HSL-RGB. Thanks yall.

callimuc

01-26-2014, 05:08 PM

converted the link fp4 has been posting into gs2 for lazy people :p

function onCreated() {

echo(rgb2hsl(234, 255, 0));

echo(hsl2rgb(196, 100, 50));

}

function rgb2hsl(r, g, b) {

temp.r = min(max(temp.r, 0), 255) / 255;

temp.g = min(max(temp.g, 0), 255) / 255;

temp.b = min(max(temp.b, 0), 255) / 255;

temp.max = max(temp.r, max(temp.g, temp.b));

temp.min = min(temp.r, min(temp.g, temp.b));

temp.h = temp.s = temp.l = (temp.max + temp.min) / 2;

if (temp.max != temp.min) {

temp.d = temp.max - temp.min;

temp.s = (temp.l > 0.5 ? temp.d / (2 - temp.max - temp.min) : temp.d / (temp.max + temp.min));

if (temp.max == temp.r)

temp.h = (temp.g - temp.b) / temp.d + (temp.g < temp.b ? 6 : 0);

else if (temp.max == temp.g)

temp.h = (temp.b - temp.r) / temp.d + 2;

else

temp.h = (temp.r - temp.g) / temp.d + 4;

temp.h /= 6;

}

else temp.h = temp.s = 0; //achromatic

return {temp.h*360,temp.s*100,temp.l*100};

}

function hsl2rgb(h, s, l) {

temp.h = min(max(temp.h, 0), 360) / 360;

temp.s = min(max(temp.s, 0), 100) / 100;

temp.l = min(max(temp.l, 0), 100) / 100;

if (temp.s > 0) {

temp.q = (temp.l < 0.5 ? (temp.l * (1 + temp.s)) : (temp.l + temp.s - (temp.l * temp.s)));

temp.p = (2 * temp.l) - temp.q;

temp.r = hue2rgb(temp.p, temp.q, temp.h + 1/3);

temp.g = hue2rgb(temp.p, temp.q, temp.h);

temp.b = hue2rgb(temp.p, temp.q, temp.h - 1/3);

}

else temp.r = temp.g = temp.b = 1; //achromatic

return {temp.r*255, temp.g*255, temp.b*255};

}

function hue2rgb(p, q, t) {

if (temp.t < 0) temp.t += 1;

if (temp.t > 1) temp.t -= 1;

if (temp.t < 1/6) return (temp.p + (temp.q - temp.p) * 6 * temp.t);

if (temp.t < 0.5) return temp.q;

if (temp.t < 2/3) return (temp.p + (temp.q - temp.p) * (2/3 - temp.t) * 6);

return temp.p;

}

function onCreated() {

echo(rgb2hsl(234, 255, 0));

echo(hsl2rgb(196, 100, 50));

}

function rgb2hsl(r, g, b) {

temp.r = min(max(temp.r, 0), 255) / 255;

temp.g = min(max(temp.g, 0), 255) / 255;

temp.b = min(max(temp.b, 0), 255) / 255;

temp.max = max(temp.r, max(temp.g, temp.b));

temp.min = min(temp.r, min(temp.g, temp.b));

temp.h = temp.s = temp.l = (temp.max + temp.min) / 2;

if (temp.max != temp.min) {

temp.d = temp.max - temp.min;

temp.s = (temp.l > 0.5 ? temp.d / (2 - temp.max - temp.min) : temp.d / (temp.max + temp.min));

if (temp.max == temp.r)

temp.h = (temp.g - temp.b) / temp.d + (temp.g < temp.b ? 6 : 0);

else if (temp.max == temp.g)

temp.h = (temp.b - temp.r) / temp.d + 2;

else

temp.h = (temp.r - temp.g) / temp.d + 4;

temp.h /= 6;

}

else temp.h = temp.s = 0; //achromatic

return {temp.h*360,temp.s*100,temp.l*100};

}

function hsl2rgb(h, s, l) {

temp.h = min(max(temp.h, 0), 360) / 360;

temp.s = min(max(temp.s, 0), 100) / 100;

temp.l = min(max(temp.l, 0), 100) / 100;

if (temp.s > 0) {

temp.q = (temp.l < 0.5 ? (temp.l * (1 + temp.s)) : (temp.l + temp.s - (temp.l * temp.s)));

temp.p = (2 * temp.l) - temp.q;

temp.r = hue2rgb(temp.p, temp.q, temp.h + 1/3);

temp.g = hue2rgb(temp.p, temp.q, temp.h);

temp.b = hue2rgb(temp.p, temp.q, temp.h - 1/3);

}

else temp.r = temp.g = temp.b = 1; //achromatic

return {temp.r*255, temp.g*255, temp.b*255};

}

function hue2rgb(p, q, t) {

if (temp.t < 0) temp.t += 1;

if (temp.t > 1) temp.t -= 1;

if (temp.t < 1/6) return (temp.p + (temp.q - temp.p) * 6 * temp.t);

if (temp.t < 0.5) return temp.q;

if (temp.t < 2/3) return (temp.p + (temp.q - temp.p) * (2/3 - temp.t) * 6);

return temp.p;

}

vBulletin® v3.8.11, Copyright ©2000-2019, vBulletin Solutions Inc.