Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

weird result while reducing saturation only of color using expression

Participant ,
Dec 10, 2021 Dec 10, 2021

I wanted to reduce only the saturation to 50% (0.5) of color and something weird happens.

Method 01

myHsl=rgbToHsl([1,0,0,1]);
myHsl[1]=0.5
hslToRgb([myHsl[0],myHsl[1],myHsl[2],1])

 

Method 2

function hexToRgb(h){
c = parseInt(h,16);
r = c >> 16;
g = (c & 0x00ff00) >> 8;
b = c & 0xff;
return [r,g,b,255]/255;
}

 

myRgb = hexToRgb("FF0000");
myHsl=rgbToHsl(myRgb );
myHsl[1]=0.5;
myUpdatedHsl=[myHsl[0],myHsl[1],myHsl[2],1];
hslToRgb(myUpdatedHsl)

 

Both method doesn't work as expected (attached)

 

I have attached pictures of results

 

please help.

 

TOPICS
Expressions
76
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
no replies

Have something to add?

Join the conversation