zoukankan      html  css  js  c++  java
  • 颜色渐变基本算法

    // 3颜色等比线性变换  
    int startColor = COLORS[colorType][0];  
    int endColor = COLORS[colorType][1];  
    int delaR = [AColor getRed:endColor] - [AColor getRed:startColor];  
    int delaG = [AColor getGreen:endColor] - [AColor getGreen:startColor];  
    int delaB = [AColor getBlue:endColor] -  [AColor getBlue:startColor];  
    LONG delaTime = SYS_TIME - publicVoiceTimeCount;  
    float rate = delaTime * 1.0f / (PublicVoice_TIME); // 0 - 1  
    int curColor = [AColor getRGB:[AColor getRed:startColor] + delaR * rate   
                                g:[AColor getGreen:startColor] + delaG * rate    
                                b:[AColor getBlue:startColor] + delaB * rate];  
    
    原来准备用这个做喇叭喊话的,但是由于渐变过度太平滑,效果不好,后来改成6颜色闪烁效果。
    
    [cpp] view plain copy
    // 闪烁效果  
    int colors[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一变  
    if (_colorCount > colorCount) {  
        colorCount = _colorCount;  
        int index = _colorCount % 6;  
        int curColor = colors[index]; } 
  • 相关阅读:
    linux(6)查看进程ps命令
    Python 基础03 序列
    Python 基础02 基本数据类型
    Python基础01 Hello World!
    Linux vi/vim
    Laravel 的HTTP控制器
    Laravel 下的伪造跨站请求保护 CSRF#
    Linux 磁盘管理
    Linux 用户he用户组管理
    Linxu 用户和用户组管理1
  • 原文地址:https://www.cnblogs.com/Free-Thinker/p/5569817.html
Copyright © 2011-2022 走看看