The basic algorithm of color gradient

Source: Internet
Author: User

//3 color equal ratio linear transformationintStartColor = colors[colortype][0]; intEndColor = colors[colortype][1]; intDelar = [Acolor Getred:endcolor]-[Acolor Getred:startcolor]; intDelag = [Acolor Getgreen:endcolor]-[Acolor Getgreen:startcolor]; intDelab = [Acolor Getblue:endcolor]-[Acolor Getblue:startcolor]; LONG Delatime= Sys_time-Publicvoicetimecount; floatRate = Delatime * 1.0f/(Publicvoice_time);//0-1intCurcolor = [Acolor getrgb:[acolor getred:startcolor] + delar *Rate G:[acolor Getgreen:startcolor]+ Delag *Rate B:[acolor Getblue:startcolor]+ Delab *Rate ]; Originally prepared to use this horn, but because the gradient over the smooth, the effect is not good, and later changed to 6 color flashing effect. [CPP] View plain copy//Flicker EffectintCOLORS[6] ={colors[colortype][0], colors[colortype][1], colors[colortype][2], colors[colortype][3], colors[colortype][2], colors[colortype][1]}; int_colorcount = (sys_time-publicvoicetimecount)/100;//1000/100s a changeif(_colorcount >Colorcount) {Colorcount=_colorcount; intindex = _colorcount% 6; intCurcolor = Colors[index]; }

The basic algorithm of color gradient

Related Article

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.