0

I'm looking for a formula to calculate the RGB of a new color, based on the opacity. Of course, there's already an answer for this (i.e. Calculating opacity value mathematically), especially this answer:

The formula for combining C1 = (R1,G1,B1) and C2 = (R2,G2,B2) into a new color C3, where C2 is overlayed on top of C1 with opacity p is usually ( (1-p)R1 + p*R2, (1-p)*G1 + p*G2, (1-p)*B1 + p*B2 ).

This is great, it works, I get the correct value. However, I need a reliable source for this formula, which I cannot find. Sure, that answer has an link to Wikipedia, which again lacks the source.

If there's any other formula for calculating the color based on the opacity value mathematically and there's a reliable source for such a formula (e.g. book or scientific paper), feel free to share it.

Thanks!

Community
  • 1
  • 1
uglycode
  • 3,022
  • 6
  • 29
  • 55
  • I do not know if this might help you but [this paper](https://www.researchgate.net/profile/Manish_Singh58/publication/4022964_Computing_layered_surface_representations_An_algorithm_for_detecting_and_separating_transparent_overlays/links/00b7d53c6923015e44000000.pdf) shows some interesting findings about transparent overlays – Rotan075 Feb 15 '16 at 09:31
  • May this might help [link]https://viget.com/inspire/equating-color-and-transparency – Mahesh Feb 15 '16 at 09:32
  • Questions asking us to find a book, tool, software library, tutorial or **other off-site resource** are off-topic for Stack Overflow – Paulie_D Feb 15 '16 at 10:35

1 Answers1

0

Thanks to anyone who helped. I actually found the answer in this link: http://jcgt.org/published/0004/02/03/paper.pdf

It's a (semi)scientific paper, and the formula is as follows: Aα * Ac + (1−Aα)*Bα*Bc / Aα + (1−Aα)*Bα

I've tested it on this scenarios:

rgb_div = (80, 85, 250); opacity = 0.2

rgb_bg = (100, 205, 30); opacity = 1

new color = (96, 181, 74)

uglycode
  • 3,022
  • 6
  • 29
  • 55