Uniform gradient
Gradient (Gradient) is an important formal beauty law in aesthetics, which corresponds to mutation. Visual factors such as shape, size, position, orientation, color, and so on, can be graded. In color, hue, lightness, purity can also produce a gradient effect, and will show a rich level of beauty. This paper mainly describes two kinds of color RGB numerical gradient algorithm.
Known: The average of a=50,b=200,a, B is divided into 3 copies (step=3), the number of each copy (STEPN) is how much.
Formula:Gradient = A + (b-a)/Step * N
[Note]: In order to improve the efficiency of the programming to avoid floating point operations, often put the division on the last side, so that the formula is: Gradient = A + (b-a) * N/step
Step=3, the step1=a+ (A-B)/3*1=50+ (200-50)/3=100,step2=a+ (A-B)/3*2=50+ (200-50)/3*2=150 can be calculated according to the formula. This is the principle of uniform gradient algorithm, very simple, primary knowledge.
The two colors of the gradient is the RGB channel of the two colors such calculations, such as two colors are RGB (200,50,0) and RGB (50,200,0), the above formula is calculated as follows:
rstep1=ra=ra+ (Ba-ra)/step*n=200+ (50-200)/3*1=200-50=150
gstep1=ga=ga+ (GA-GA)/step*n=50+ (200-50)/3*1=50+50=100
bstep1=ba=ba+ (BA-BA)/step*n=0
So rgbstep1= (150,100,0), the same method can be obtained rgbstep2= (100,150,0).
RGB Calculations for color gradients