I want to implement color blending as described in the W3C compositing and blending spec. (I'm doing this in JavaScript but the language shouldn't really matter for solving my problem.)
In retrospect: During the implementation of the answer to this question I realized that this would probably make for a pretty nice standalone package. In case you're interested you can grab it from npm.
It worked out pretty well so far but I wanted to take these algorithms a step further and add support for alpha channels. Thanks to the SVG compositing spec providing all the needed formulas that wasn't too hard.
But now I'm stuck with implementing the blend modes that the W3C spec describes as non-separable which are (as known from Photoshop): hue, saturation, color and luminosity.
Sadly, algorithms for those aren't available in the SVG spec and I have no idea how to work with those. I guess there are a modified versions of the formulas provided by the W3C for working with alpha channels which I'm missing.
To make my problem a little more visual I'll show what Photoshop gives me for hue blending two colors:
This is what I'm also able to reproduce with the non-alpha algorithm from the mentioned W3C spec.
What I can't reproduce is the result that Photoshop gives me when I put a lower alpha on both the source and the backdrop color:
Does anyone know how to achieve that result programmatically?
Update 1: Changed illustrations (adding HSVA and RGBA codes) to clarify the used colors.
Update 2: To check possible solutions I'll attach two other Photoshop-generated blending examples:
Update 3: So it turned out that in addition to not having a clue about color blending I also messed up my Photoshop settings, making the task to solve my question even harder. Fixed the example images for possible future passerbies.