+
Skip to content

Feature suggestion: Support mixing with different blend modes #99

@loilo

Description

@loilo

I was about to write my own color library with a nicely clean API which in the end I found to resemble your approach very closely. So I screwed that over and instead would like to propose one big feature I wanted to have in my toolkit but that's missing in this library.

What

I planned a feature that allows mixing of colors not only with the standard "source-over" algorithm but with all the standard blend modes that Photoshop and the W3C are presenting.

Who

It was a little tricky to find the algorithms for all the blend modes with alpha channel taken into account but I invested quite some time in researching and eventually was successful. So I already completely implemented all the blend modes in TypeScript—it shouldn't be too hard to transfer the implementations to this library. I'd be happy to attach a PR.

How

Now comes the tricky part: What I'm not sure about is how to—in case you're positive about this feature at all—integrate that thing into the existing API.

The feature would probably need an all new .blend() method as a kind of "enhanced" .mix() because

a) every architectural approach I took to adjust the .mix() parameters for this feature introduced some kind of design flaw.
b) using the existing .mix() at all would only work sanely if it by default handled color mixing exactly like the normal blend mode does—which isn't the case. That would require calculating the resulting alpha in a different way than just averaging the alphas of the mixed colors.

You got any thoughts on this? Do you like the idea? What would be your approach with the API facet?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载