Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Showimg HSL (https://forums.graalonline.com/forums/showthread.php?t=134269032)

sssssssssss 01-24-2014 03:15 PM

Showimg HSL
 
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/2...lor-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

Quote:

Originally Posted by sssssssssss (Post 1725461)
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.

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

Quote:

Originally Posted by sssssssssss (Post 1725491)
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"?

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.

callimuc 01-26-2014 05:08 PM

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

PHP Code:

function onCreated() {
  echo(
rgb2hsl(2342550));
  echo(
hsl2rgb(19610050));
}


function 
rgb2hsl(rgb) {
  
temp.min(max(temp.r0), 255) / 255;
  
temp.min(max(temp.g0), 255) / 255;
  
temp.min(max(temp.b0), 255) / 255;
  
  
temp.max max(temp.rmax(temp.gtemp.b));
  
temp.min min(temp.rmin(temp.gtemp.b));
  
  
temp.temp.temp.= (temp.max temp.min) / 2;
  
  if (
temp.max != temp.min) {
    
temp.temp.max temp.min;
    
temp.= (temp.0.5 temp./ (temp.max temp.min) : temp./ (temp.max temp.min));
    if (
temp.max == temp.r)
      
temp.= (temp.temp.b) / temp.+ (temp.temp.0);
    else if (
temp.max == temp.g)
      
temp.= (temp.temp.r) / temp.2;
    else
      
temp.= (temp.temp.g) / temp.4;
    
temp./= 6;
  }
  else 
temp.temp.0//achromatic
  
  
return {temp.h*360,temp.s*100,temp.l*100};
}

function 
hsl2rgb(hsl) {
  
temp.min(max(temp.h0), 360) / 360;
  
temp.min(max(temp.s0), 100) / 100;
  
temp.min(max(temp.l0), 100) / 100;
  if (
temp.0) {
    
temp.= (temp.0.5 ? (temp.* (temp.s)) : (temp.temp.- (temp.temp.s)));
    
temp.= (temp.l) - temp.q;
    
    
temp.hue2rgb(temp.ptemp.qtemp.1/3);
    
temp.hue2rgb(temp.ptemp.qtemp.h);
    
temp.hue2rgb(temp.ptemp.qtemp.1/3);
  }
  else 
temp.temp.temp.1//achromatic
  
  
return {temp.r*255temp.g*255temp.b*255};
}
function 
hue2rgb(pqt) {
  if (
temp.0temp.+= 1;
  if (
temp.1temp.-= 1;
  
  if (
temp.1/6) return (temp.+ (temp.temp.p) * temp.t);
  if (
temp.0.5) return temp.q;
  if (
temp.2/3) return (temp.+ (temp.temp.p) * (2/temp.t) * 6);
  return 
temp.p;




All times are GMT +2. The time now is 08:43 PM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.