颜色取反
2016-06-07 10:25
363 查看
方法即是
0xFFFFFF - $oldcolor
转自
http://zhidao.baidu.com/question/143793592.html?push=ql
echo dechex(0xFFFFFF - $oldcolor);
把原文贴出来吧,不然可能不知道怎么来的。
You can invert a color by subtracting each of its red, green, and blue components from 255. In other words:
new_red = 255 - old_red
new_green = 255 - old_green
new_blue = 255 - old_blue
You can break a color into its components, use this technique to invert the components, and then use RGB to recombine them into the inverted color. However, there is a much simpler method.
If a color's components are given as R, G, and B, then the color is represented as:
R + 256 * G + 256 * 256 * B
Now consider the representation of inverse of this color with components 255 - R, 255 - G, and 255 - B:
(255 - R) + 256 * (255 - G) + 256 * 256 * (255 - B)
= (255 + 256 * 255 + 256 * 256 * 255) -
(R + 256 * G + 256 * 256 * B)
= &HFFFFFF - the_original_color
So a simpler method for calculating the inverse of a color is:
new_color = &HFFFFFF - old_color
0xFFFFFF - $oldcolor
转自
http://zhidao.baidu.com/question/143793592.html?push=ql
echo dechex(0xFFFFFF - $oldcolor);
把原文贴出来吧,不然可能不知道怎么来的。
You can invert a color by subtracting each of its red, green, and blue components from 255. In other words:
new_red = 255 - old_red
new_green = 255 - old_green
new_blue = 255 - old_blue
You can break a color into its components, use this technique to invert the components, and then use RGB to recombine them into the inverted color. However, there is a much simpler method.
If a color's components are given as R, G, and B, then the color is represented as:
R + 256 * G + 256 * 256 * B
Now consider the representation of inverse of this color with components 255 - R, 255 - G, and 255 - B:
(255 - R) + 256 * (255 - G) + 256 * 256 * (255 - B)
= (255 + 256 * 255 + 256 * 256 * 255) -
(R + 256 * G + 256 * 256 * B)
= &HFFFFFF - the_original_color
So a simpler method for calculating the inverse of a color is:
new_color = &HFFFFFF - old_color
相关文章推荐
- perl 循环删除指定文件夹下所有满足条件的文件,不包含文件夹
- css3 transform
- android 之图片异步加载
- 实验二. 使用LoadRunner进行压力测试
- db2表出现deadlock死锁,返回码为2或者68
- 不说话的“狼人杀”游戏
- android 加速度传感器,重力传感器,线性加速度传感器
- Swift 算法实战之路:数组,字符串,集合,与字典
- id to load is required for loading
- 转:ffmpeg官网
- 算法:康托展开式——实现全排列序列与序号的映射
- Apache Commons工具集简介
- 如何处理有换行的字符串,算高度
- leetcode-java-3. Longest Substring Without Repeating Characters
- C# Struct的特点
- linux CENTOS下安装R环境
- NFS精简版配置方法
- MFC+Opencv显示图像的几种方法
- LCP242 LeetCode 242. Valid Anagram
- iOS开发拓展篇—音效的播放