I am doing some blendMode(BURN) to paint some shapes. And other shapes I need to painted directly in the resulting color of the previous shapes, so I need to generate the blended resulting color my self.
I am looking for something like:
let blendedColor = blendColorsBurn(color1, color2);
There's no built in function for this. In 2d mode p5.js leverages the canvas's
globalCompositeOperationproperty, which when set tocolor-burnperforms the following color blending operation:This sounds simple enough, but I wanted to verify it means what it sounds like it means, so I decided to try a quick test implementation. Press the shift and control keys to see the built in BURN blendMode vs my calculations respectively.
There were definitely some gotchas:
colorMode(RGB, 1, 1, 1, 1)does not work because thered(),green(), andblue()function round to integers ♂️