I have a RGB color that represents light. I am looking for an algorithm to draw this over an arbitrary background (could be, for example, an image) in a way that simulates (or resembles) lighting.
Some examples:
RGB=#888888 represents white light at 50% intensity
- Painting this over white (#ffffff) background pixels would do nothing
- Painting this over black (#000000) background pixels would paint as #888888
- Painting this over red (#ff0000) background pixels would result in a "lighter red"
RGB=#ff0000 represents red light at 100% intensity
- Painting this over white (#ffffff) background pixels should result in a "light red" (mix of red and white)
- Painting this over black (#000000) background pixels would paint as #880000
RGB=#000000 represents no light. Painting this over any background should have no effect.
I was hoping that I would be able to translate the original RGB color in (a set of) RGBA color(s) that I could paint over the background. I have been looking for an algorithm for this and playing around with HSL, HSB, alpha, etc. but cannot find a generic way to accomplish this.
Is there a generic algorithm to achieve what I want?
Update: I am aware of this question, but I don't think this is a duplicate (despite the similar names). The accepted answer to that question describes a behaviour (Red + Black = Dark red) that does not match this sceneario (lighting). I am specifically looking for an algorithm to simulate (colored) lighting.