Part 1 covered RGB. Part 2 added alpha. Now the question that's been hanging: if you put 50% black on a white background, what color does the user see?

A transparent color has no fixed look

#80000000 is roughly half-opaque black. Over white it looks gray. Over blue it looks dark blue. Over red, dark red. The color on its own doesn't decide the result. What's behind it does.

The color on top is the foreground, the one underneath is the background.

The formula

For each channel:

result = foreground × alpha + background × (1 - alpha) 

Alpha here is 0.0 to 1.0, so 50% is 0.5. At 0.5, foreground and background contribute equally.

50% black over white

Take one channel. White is 255, black is 0, alpha is 0.5:

0 × 0.5 + 255 × 0.5 = 127.5 

That rounds to 128, or 80 in hex. The result is #808080, a mid gray.

At 20% black over white:

0 × 0.2 + 255 × 0.8 = 204 

204 is CC, so #CCCCCC, a light gray. At 80%:

0 × 0.8 + 255 × 0.2 = 51 

51 is 33, so #333333, quite dark.

Doing it for all three channels

Run the same formula on red, green and blue separately. Say the foreground is 50% opaque red, RGB(255, 0, 0), over white, RGB(255, 255, 255):

Red: 255 × 0.5 + 255 × 0.5 = 255 Green: 0 × 0.5 + 255 × 0.5 = 127.5 → 128 Blue: 0 × 0.5 + 255 × 0.5 = 127.5 → 128 

That gives RGB(255, 128, 128), or #FF8080. A light pink.

Same overlay, different result

This is why the same code can look different in different places. #80000000 over white comes out around #808080. Over blue, #0000FF, it comes out around #000080. The overlay didn't change. The background did.

Overlays and gradients

The usual use is readability. You have a photo with white text on it, and a bright patch of sky makes the text hard to read. Put a #80000000 layer between them. The image gets darker, the text stays white, contrast goes up.

Gradients use the same trick. Keep the RGB fixed at black and only change alpha:

#00000000 top, invisible #80000000 middle, half #FF000000 bottom, solid black 

That's a gradient of opacity, not of hue. It's the standard way to make a caption area at the bottom of an image.

Layers

Real interfaces stack several layers: text on a card, on an overlay, on an image, on a page background. Each can have its own alpha, and the renderer blends them from back to front. A color you see on screen may be the result of four or five blends.

Source color vs rendered color

This one catches people. Say you've got #80000000 over a blue background, and you point a color picker at the screen. It reports something like #000080. It's tempting to conclude the designer chose dark blue. They didn't. They used 50% black over blue.

A color picker reads the final rendered pixel. Your code specifies the source color. When something looks off, ask which one you're looking at.

Two mistakes to avoid

First, opacity vs transparency again. "20% transparent black" is 80% opaque, alpha CC. "20% opaque black" is alpha 33. Those are very different overlays.

Second, assuming alpha position. #80FF0000 in ARGB is #FF000080 in RRGGBBAA. Copying an eight-digit code between platforms without checking is a good way to get a color that's wrong in a confusing way.

Debugging a color

Don't squint at the whole string. Split it. For #B4555555:

B4 55 55 55 A R G B 

Then ask:

  • What's the alpha?
  • What's the RGB?
  • What's behind it?
  • Is there another layer?
  • Does this platform use AARRGGBB or RRGGBBAA?

The whole chain

RGB → hex → alpha → opacity → blending → rendered color 

#FF0000 is red. #80FF0000 is about 50% opaque red. What you see depends on what's under it.

Cheat sheet

RGB #RRGGBB #FF0000 = red ARGB #AARRGGBB #80FF0000 = ~50% opaque red alpha = opacity × 255 / 100 opacity = alpha × 100 / 255 100% FF 90% E6 80% CC 70% B3 60% 99 50% 80 40% 66 30% 4D 20% 33 10% 1A 0% 00 

Check each platform's alpha order. Some use #AARRGGBB, some use #RRGGBBAA, and some take alpha separately.

You don't need to memorize hex colors. If you can look at #B4555555 and see B4 | 55 | 55 | 55 as alpha, red, green, blue, you understand how they're built, and that's enough.