Output Color

Loading… Please Wait

About RGBA to HWB Converter

Input an RGBA value like rgba(255, 0, 255, 0.5) and RGBA to HWB converter will convert this value to an HWB color like hwb(300deg 0% 0% / 0.5).

RGBA color parameters are red, green, blue, and alpha. The output HWB color parameters are hue, whiteness, blackness, and alpha.

Why Convert RGBA to HWB?

Converting RGBA to HWB is useful when you need to define colors in terms of their hue, whiteness, and blackness. HWB is an alternative color model that emphasizes the amount of white and black mixed with a base hue, providing a different way to manipulate and represent colors. This format is helpful for creating color palettes that are more intuitive in some design contexts.

How to Convert RGBA to HWB

To convert RGBA to HWB, follow these steps to transform the red, green, and blue components into hue, whiteness, and blackness, and then include the alpha component.

  1. Extract the values for Red (R), Green (G), Blue (B), and Alpha (A) from the RGBA code.
    • Example: rgba(25, 199, 71, 0.5) gives R = 25, G = 199, B = 71, A = 0.5.
  2. Convert the RGB values to a range of 0 to 1 by dividing by 255.
    • R = 25 / 255 ≈ 0.098
    • G = 199 / 255 ≈ 0.780
    • B = 71 / 255 ≈ 0.278
  3. Calculate the minimum and maximum values among the normalized R, G, and B values, and find the difference.
    • Max = 0.780
    • Min = 0.098
    • Delta = Max – Min = 0.780 – 0.098 ≈ 0.682
  4. Calculate Hue (H).
    • If Max = R, H = 60 × ((G – B) / Delta % 6)
    • If Max = G, H = 60 × ((B – R) / Delta + 2)
    • If Max = B, H = 60 × ((R – G) / Delta + 4)
    • Example: Max = G, so H = 60 × ((0.278 – 0.098) / 0.682 + 2) ≈ 136 degrees
  5. Calculate Whiteness (W).
    • W = Min
    • Example: W = 0.098
  6. Calculate Blackness (B).
    • B = 1 – Max
    • Example: B = 1 – 0.780 = 0.22
  7. Convert Whiteness (W) and Blackness (B) to a percentage:
    • W = 0.098 × 100 ≈ 10%
    • B = 0.22 × 100 ≈ 22%
  8. Combine the HWB values.
    • Example: hwb(136deg 10% 22% / 0.5)

List of Color Tools