RGB Calculations for color gradients

Source: Internet
Author: User
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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.