颜色渐变实用获取色值方法
来源:互联网 发布:sql minus 但不去重 编辑:程序博客网 时间:2024/05/04 22:33
/** * 计算渐变颜色值 ARGB * * @param fraction * 变化比率 0~1 * @param startValue * 初始色值 * @param endValue * 结束色值 * @return */private Integer evaluate(float fraction, Object startValue, Integer endValue) {int startInt = (Integer) startValue;int startA = (startInt >> 24) & 0xff;int startR = (startInt >> 16) & 0xff;int startG = (startInt >> 8) & 0xff;int startB = startInt & 0xff;int endInt = (Integer) endValue;int endA = (endInt >> 24) & 0xff;int endR = (endInt >> 16) & 0xff;int endG = (endInt >> 8) & 0xff;int endB = endInt & 0xff;return (int) ((startA + (int) (fraction * (endA - startA))) << 24)| (int) ((startR + (int) (fraction * (endR - startR))) << 16)| (int) ((startG + (int) (fraction * (endG - startG))) << 8)| (int) ((startB + (int) (fraction * (endB - startB))));}
使用方法很简单:
int color = evaluate(0.5f, Color.BLACK, Color.WHITE);
0 0
- 颜色渐变实用获取色值方法
- CSS3颜色值RGBA与渐变色
- ios 实现颜色渐变(渐变色)
- APP实用开发—ScrollView滑动标题栏颜色渐变
- 字体颜色渐变和边框渐变的一个方法
- 获取过度颜色百分比及设置背景颜色渐变
- CSS滤镜:颜色渐变[微软的方法]
- CSS滤镜:颜色渐变[微软的方法]
- [原]CSS实现颜色渐变方法备忘
- swing 设置背景颜色渐变的方法
- 设置view的颜色渐变的方法
- 实现颜色渐变的几种方法
- 获取图片 渐变色
- 颜色渐变
- 颜色渐变
- 颜色渐变
- 颜色渐变
- 颜色渐变
- Android从入门到精通第12章:线程与消息处理
- Raspberry pi,一个好玩的派:第一季 开源硬件
- SQL Case when 的使用方法
- cannot find class [xxx] for bean with name
- javascript扩展date对象格式化日期时间输出
- 颜色渐变实用获取色值方法
- emoji 符号
- 【工程数学】若干种解高次方程的算法
- flas和js的交互(聊天室的另一种解决方案)
- Docker安全性(一)——Docker容器真的安全吗?
- libstdc++.so.6: cannot open shared object file: No such file or directory
- git报错:error: The requested URL returned error: 403 Forbidden while accessing https://github.com/summ
- Verilog中的关于文件操作的函数和任务
- java多线程使用集合那点事