Output Color

Loading… Please Wait

About HSL to RGBA Converter

Input an HSL value like hsl(180deg, 100%, 50%) and Diversify India’s HSL to RGBA converter will convert this value to an RGBA color like rgba(0, 255, 255, 1).

HSL color parameters are hue, saturation, and lightness. The output RGBA color parameters are red, green, blue, and alpha.

Why Convert HSL to RGBA?

Converting HSL to RGBA is useful when you need to define colors in terms of their hue, saturation, and lightness along with opacity. RGBA is often used in digital design and web development for its straightforward representation of color and transparency.

How to Convert HSL to RGBA

To convert HSL to RGBA, you need to transform the hue, saturation, and lightness components into red, green, and blue values, and then include the alpha component.

  1. Extract the values for Hue (H), Saturation (S), Lightness (L), and Alpha (A) from the HSL code.
    • Example: hsl(320deg, 60%, 50%) gives H = 320, S = 60%, L = 50%.
  2. Convert the Saturation (S) and Lightness (L) values to a range of 0 to 1 by dividing by 100.
    • ๐‘† = 60% / 100 = 0.6
    • L = 50% / 100 = 0.5
  3. Calculate the intermediate values for chroma (C), X, and m.
    • Chroma ๐ถ = (1 – โˆฃ2๐ฟ – 1โˆฃ) ร— S
    • X = ๐ถ ร— (1 – โˆฃ(๐ป / 60) % 2 – 1โˆฃ)
    • m = ๐ฟ – (๐ถ / 2)
  4. Example Calculation:
    • C = (1 – โˆฃ2 ร— 0.5 – 1โˆฃ) ร— 0.6 = 0.6
    • X = 0.6 ร— (1 – โˆฃ(320 / 60) % 2 – 1โˆฃ) = 0.4
    • m = 0.5 – (0.6 / 2) = 0.2
  5. Calculate the Red (R), Green (G), and Blue (B) values based on the Hue (H) range.
    • For 0 โ‰ค ๐ป <60: (๐‘…, ๐บ, ๐ต) = (๐ถ + ๐‘š, ๐‘‹ + ๐‘š, ๐‘š)
    • For 60 โ‰ค ๐ป < 120: (๐‘…, ๐บ, ๐ต) = (๐‘‹ + ๐‘š, ๐ถ + ๐‘š, ๐‘š)
    • For 120 โ‰ค ๐ป <180: (๐‘…, ๐บ, ๐ต) = (๐‘š, ๐ถ + ๐‘š, ๐‘‹ + ๐‘š)
    • For 180 โ‰ค ๐ป < 240: (๐‘…, ๐บ, ๐ต) = (๐‘š, ๐‘‹ + ๐‘š, ๐ถ + ๐‘š)
    • For 240 โ‰ค ๐ป < 300: (๐‘…, ๐บ, ๐ต) = (๐‘‹ + ๐‘š, ๐‘š, ๐ถ + ๐‘š)
    • For 300 โ‰ค ๐ป < 360: (๐‘…, ๐บ, ๐ต) = (๐ถ + ๐‘š, ๐‘š, ๐‘‹ + ๐‘š)
    • Example: Since H = 320, (๐‘…, ๐บ, ๐ต) = (0.6 + 0.2, 0.2, 0.4 + 0.2) = (0.8, 0.2, 0.6)
  6. Convert the RGB values to a scale of 0 to 255.
    • ๐‘… = 0.8 ร— 255 โ‰ˆ 204
    • ๐บ = 0.2 ร— 255 โ‰ˆ 51
    • ๐ต = 0.6 ร— 255 โ‰ˆ 153
  7. The Alpha value spans from 0 (fully transparent) to 1 (fully opaque). You can choose the desired alpha value based on the transparency needed.
    • Example: Adding an alpha value of 0.5 for 50% transparency.
  8. Combine the RGB values with the Alpha (A) value to form the RGBA value.
    • Example: rgba(204, 51, 153, 0.5)

List of Color Tools