Input type | Output type |
color, color, float | color |
The compose function accepts three parameters: two colors and a floating-point value. It composes the second color on top of the first color. The third parameter specifies the opacity (0..1) of the second color. This function takes the alpha values of the two colors into account to compose them correctly.
With this function, you can reproduce how layers are merged. Use the following formula to merge t on top of b with opacity o:
compose(b, blend(t, mergeX(b, t), alpha(b)), o)
Examples:
compose(rgb(1, 0, 0), rgba(0, 1, 0, 0.5), 0) ; rgba(1, 0, 0, 1) compose(rgb(1, 0, 0), rgba(0, 1, 0, 0.5), 0.5) ; rgba(0.75, 0.25, 0, 1) compose(rgb(1, 0, 0), rgba(0, 1, 0, 0.5), 1) ; rgba(0.5, 0.5, 0, 1)
See Also
blend function
Merging functions
Writing direct coloring
algorithms