RGBA to HSL Converter

RGBA (red-green-blue-alpha) and HSL (hue-saturation-lightness) are two different color models used to represent colors in digital graphics. RGBA represents a color using its red, green, blue, and alpha (transparency) values, while HSL represents a color using its hue, saturation, and lightness values.

To convert RGBA to HSL, you can use the following formulas:

First, convert the RGB values to a range of 0 to 1 by dividing each value by 255:

R' = R / 255

G' = G / 255

B' = B / 255

Then, find the maximum and minimum values of the R', G', and B' values:

Cmax = max(R', G', B')

Cmin = min(R', G', B')

Next, calculate the hue (H) value using the following formula:

If Cmax = Cmin, H = 0

Else if Cmax = R', H = 60 * ((G' - B') / (Cmax - Cmin)) mod 360

Else if Cmax = G', H = 60 * ((B' - R') / (Cmax - Cmin)) + 120

Else if Cmax = B', H = 60 * ((R' - G') / (Cmax - Cmin)) + 240

Note: the mod 360 is used to ensure that H is in the range of 0 to 360.

Then, calculate the lightness (L) value using the following formula:

L = (Cmax + Cmin) / 2

Finally, calculate the saturation (S) value using the following formula:

If Cmax = Cmin, S = 0

Else if L ≤ 0.5, S = (Cmax - Cmin) / (Cmax + Cmin)

Else if L > 0.5, S = (Cmax - Cmin) / (2 - (Cmax + Cmin))

Once you have calculated the H, S, and L values, you can convert them to hexadecimal values to get the corresponding HSL color code.

Similar tools

RGBA to HEX Converter

Convert your RGBA color format to HEX format.

0
RGBA to HEXA Converter

Convert your RGBA color format to HEXA format.

0
RGBA to RGB Converter

Convert your RGBA color format to RGB format.

0
RGBA to HSV Converter

Convert your RGBA color format to HSV format.

0
RGBA to HSLA Converter

Convert your RGBA color format to HSLA format.

0

Popular tools