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.
Related tools
The print size calculator relates pixels to print dimensions and the aspect ratio calculator keeps the proportions of an image.