Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maths for color gradient [closed]

Is any Maths for making a (simple) color gradient? I'm looking for simple methods of making a gradient. Not in a specific language. Just the maths of colors.

like image 836
Vassilis Avatar asked Sep 23 '12 17:09

Vassilis


1 Answers

In general, a colour gradient is a linear function for easing from one colour to another. For instance, if you wanted to produce a gradient from red (100%, 0%, 0%) to blue (0%, 0%, 100%), you would sweep each colour value from its initial value to its target value.

enter image description here

At the middle of the gradient, the colour value would be equal to 50% of the first colour, added to 50% of the second colour. In this example, you'd end up with (50%, 0%, 50%) - which is equal to purple.

like image 194
Peter Sobot Avatar answered Sep 27 '22 16:09

Peter Sobot