Skip to content
Omnikalc

Alpha blending calculator: what color results from an opacity?

Enter a top color, a background color and an opacity to get the resulting RGB color and its luminance, as in CSS rgba() or an image layer.

Updated on
Your inputs

Value out of range

Value out of range

Value out of range

Value out of range

Value out of range

Value out of range

%

Value out of range

Results

Resulting red

255

Resulting green
153
Resulting blue
153
Relative luminance of the result
0.4634

A semi-transparent color on a web page or in a design looks different on each background, and sometimes you need the plain color it produces. The alpha blending calculator takes a top color, a background color and an opacity to give the resulting RGB color and its relative luminance.

How the calculation works

  • Alpha = opacity ÷ 100, from 0 (invisible) to 1 (solid).
  • Each channel of the result = alpha × the top color + (1 − alpha) × the background. This is the standard “over” operation used by CSS, image editors and graphics libraries for a background that is opaque.
  • The three results are rounded to whole numbers from 0 to 255. You can turn them into a hex code or use them as rgb(r, g, b).
  • The relative luminance of the result is computed with the WCAG formula, so you can check the contrast of text that sits on the blended color.

Example

A red overlay of rgb(255, 0, 0) at 40% opacity over a white background. Red = 0.4 × 255 + 0.6 × 255 = 255. Green = 0.4 × 0 + 0.6 × 255 = 153. Blue = 0.4 × 0 + 0.6 × 255 = 153. The result is rgb(255, 153, 153), a light red, with a relative luminance of about 0.46.

Why it matters

Opacity is used for overlays, shadows, hover effects and glass-like panels. Finding the flat result lets you reproduce the look in places that do not support transparency, and check the contrast of text on top of it.

Good to know

The calculator assumes an opaque background. If the background is itself transparent, blend it with what is beneath first. Opacity applied to a whole element, including its text, differs from an alpha value in a color. Colors are rounded to whole numbers, so a result may differ by one unit from what a program shows. Check text contrast on the result and not on the top color alone.

The print size calculator relates pixels to print dimensions and the aspect ratio calculator keeps the proportions of an image.

Frequently asked questions

How does opacity change a color?

A color with opacity lets the background show through. The result is a weighted average of the two colors: the opacity gives the weight of the top color and one minus the opacity the weight of the background. At 100% you see only the top color, and at 0% only the background.

How do I find the flat color of an rgba color?

Enter the color of rgba as the top color, its alpha as the opacity and the page color as the background. The result is the solid color that looks the same on that background. This is useful when you cannot use transparency, as in an email, a PDF or a logo for print.

Does the order matter?

Yes. Putting red at 40% over white is not the same as white at 40% over red. The top color is the one with the opacity. When you stack several layers, blend the bottom pair first and then blend the result with the next layer above.

Is the blend the same in every program?

Most programs blend in the sRGB values, as this calculator does. Some, such as certain 3D tools, blend in linear light, which gives lighter midtones. The difference is visible for strong colors at 50% opacity, and the sRGB blend is the one browsers use for CSS.

Was this calculator helpful?

Thanks for your feedback!

Results are estimates provided for information purposes. They do not replace professional advice.