美文网首页
颜色相关代码

颜色相关代码

作者: zhaoyubetter | 来源:发表于2016-11-21 16:55 被阅读12次

颜色渐变

/** fraction : 分量 
private int evaluate(float fraction, int startValue, int endValue) {
        int startInt = startValue;
        int startA = (startInt >> 24);
        int startR = (startInt >> 16) & 0xff;
        int startG = (startInt >> 8) & 0xff;
        int startB = startInt & 0xff;

        int endInt = endValue;
        int endA = (endInt >> 24);
        int endR = (endInt >> 16) & 0xff;
        int endG = (endInt >> 8) & 0xff;
        int endB = endInt & 0xff;

        return ((startA + (int) (fraction * (endA - startA))) << 24) | ((startR + (int) (fraction * (endR - startR))) << 16) | ((startG + (int) (fraction * (endG - startG))) << 8)
                | ((startB + (int) (fraction * (endB - startB))));
    }

获取深色与暗色

 private int getDarkColor(int color) {
        int red = Color.red(color);
        int green = Color.green(color);
        int blue = Color.blue(color);
        return 0XFF000000 | getOffsetIntValue(red,-20) << 16 | getOffsetIntValue(green,-20) << 8 | getOffsetIntValue(blue,-20);
    }

    private int getDeepColor(int color) {
        int red = Color.red(color);
        int green = Color.green(color);
        int blue = Color.blue(color);
        return 0XFF000000 | getOffsetIntValue(red,20) << 16 | getOffsetIntValue(green,20) << 8 | getOffsetIntValue(blue,20);
    }

动态改变 Progress 的颜色

 if(Build.VERSION.SDK_INT>= Build.VERSION_CODES.LOLLIPOP){
            progressBar.getIndeterminateDrawable().setColorFilter(color, PorterDuff.Mode.SRC_IN);
        }

相关文章

  • 颜色相关代码

    颜色渐变 获取深色与暗色 动态改变 Progress 的颜色

  • JavaScript实例-页面特效1-改变背景色

    功能一:修改文档的背景颜色 代码: 相关知识点 document颜色相关的属性如下:bgColor:背景色fgCo...

  • 辛巴的色彩研习报告「16」颜色解析之绿色

    ·绿色(green)(颜色代码00FF00) 绿色是自然界中常见的颜色,和大自然与植物紧密相关。绿色是很特别的颜色...

  • 随机颜色

    flutter 产生随机颜色 相关代码如下: 需要导入以下两个 有了随机颜色妈妈再也不用但心选择颜色了~ 哈哈哈哈...

  • Matplotlib实现同心圆上两点连线动态叠加图

    如题,示例代码如下: 相关知识点: 1.设置曲线的rgba颜色 示例中的代码为line = ax.plot([x1...

  • 颜色相关

  • 颜色相关

    颜色:3种颜色通道 R G B 颜色表达方式: 24位,32位每一个颜色通道是8位,0~256R:213 G:21...

  • CSS颜色代码参照表

                             颜色名称         代码        颜色

  • 工作中一些细小的经验总结

    代码相关 字符串,颜色和尺寸等资源尽量在资源文件中定义,以便代码规范和方便修改。 方法,变量等命名尽量通俗易懂 获...

  • Character2

    上次说到很简单的shader,这次来用颜色可视化模拟和顶点相关的数据,代码如下: 从#include "Unity...

网友评论

      本文标题:颜色相关代码

      本文链接:https://www.haomeiwen.com/subject/tupupttx.html