Uniform gradient The following are theories: Gradient is an important formal beauty law in aesthetics. It corresponds to a mutation. Shape, size, position, direction, color, and other visual factors can be gradient. In color, the color phase, brightness, and purity can also produce gradient effects, and will show a variety of aesthetic levels. This article describes the gradient of two color RGB values.Algorithm. Known: A = 50, B = 200, A and B are evenly divided into three parts (step = 3), and the value of each part (stepn) is calculated respectively. Formula:Gradient = a + (B-A)/step * n [Note] in programming to improve efficiency to avoid floating point operations, division is often placed at the end of the formula: gradient = a + (B-A) * n/step Step = 3, according to the formula can be obtained Step1 = a + (A-B)/3 *1= 50 + (200-50)/3 =100, Step 2 = a + (A-B)/3 *2= 50 + (200-50)/3*2 = 150. This is the principle of the even gradient algorithm. It is very simple, with primary knowledge. The gradient of the two colors is calculated for the RGB channels of the two colors. For example, the two colors are RGB (50,200, 50, 0) and RGB (, 0 ), the above formula is used for calculation: Rstep1 = 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)/step * n =0 Therefore, rgbstep1 = (150,100, 0). You can use the same method to obtain rgbstep2 = (100,150, 0 ). |