|
|
|
|
|
by mwkaufma
434 days ago
|
|
>> The mix function is an interpolation function that linearly interpolates between the two input colors using a blend factor between and ( in our case). >> A mix function for two colors works the same way, except we mix the color components. To mix two RGB colors, for example, we’d mix the red, green, and blue channels. Colorspace alert! mix != lerp in sRGB |
|
I do disagree with the article about the need to do such work in the WebGL space. Modern CPUs are insanely fast nowadays, and browsers have put in a lot of work over the past few years to make the Canvas 2D API as performant as possible - including moving as much work as possible into the GPU behind the scenes. With a bit of effort, gradients can be animated in 2D canvases in many interesting ways![2][3]
[1] - Easing a linear gradient in different color spaces: https://scrawl-v8.rikweb.org.uk/demo/canvas-003.html
[2] - Animated gradient effect: https://codepen.io/kaliedarik/pen/poRLBLp
[3] - Animating a gradient over a live video feed: https://codepen.io/kaliedarik/pen/MWMQyJZ