kimikage / ColorBlendModes.jl

blend modes such as multiply, screen, overlay and so on.
MIT License
4 stars 0 forks source link

More composite operations support for opaque backdrop #26

Closed kimikage closed 4 years ago

kimikage commented 4 years ago

The alpha composition is a type of operations on transparent colors. Especially if the backdrop is an opaque color, it cannot represent the transparent result. However, I do not want to promote the backdrop from Color to TransparentColor for the sake of consistency.

However, for some operations, if the backdrop is opaque, the result will always be opaque as well. Currently, only the default CompositeSourceOver supports the opaque backsdrop.

julia> CompositeSourceOver(RGB(0), RGB(0)) # the default op
RGB{N0f8}(0.0,0.0,0.0)

julia> CompositeDestination(RGB(0), RGB(0))
ERROR: MethodError: no method matching

julia> CompositeDestinationOver(RGB(0), RGB(0))
ERROR: MethodError: no method matching

julia> CompositeSourceAtop(RGB(0), RGB(0))
ERROR: MethodError: no method matching

julia> CompositeLighter(RGB(0), RGB(0)) # The spec. of "Lighter" is unclear, though.
ERROR: MethodError: no method matching

While opaque backdrop support is not so useful for the two-color compositing, they can be useful in the future when supporting the compositing of three or more colors .