RandomColor
来源:互联网 发布:linux dns安装 编辑:程序博客网 时间:2024/05/19 07:28
/**
*
*/
package utils;
/**
* @Title:RandomColor.java
* @Package: utils
* @Description:生成随机颜色
* @author:LJJ
* @date:2014-1-15 下午11:29:51
* @version V1.0
*/
import java.util.Random;
/**
*
* @author:LJJ
* @date:2014-1-15 下午11:29:51
* @version V1.0
*/
public class RandomColor {
public static String getColor() {
// 红色
String red;
// 绿色
String green;
// 蓝色
String blue;
// 生成随机对象
Random random = new Random();
// 生成红色颜色代码
red = Integer.toHexString(random.nextInt(256)).toUpperCase();
// 生成绿色颜色代码
green = Integer.toHexString(random.nextInt(256)).toUpperCase();
// 生成蓝色颜色代码
blue = Integer.toHexString(random.nextInt(256)).toUpperCase();
// 判断红色代码的位数
red = red.length() == 1 ? "0" + red : red;
// 判断绿色代码的位数
green = green.length() == 1 ? "0" + green : green;
// 判断蓝色代码的位数
blue = blue.length() == 1 ? "0" + blue : blue;
// 生成十六进制颜色值
String color = "#" + red + green + blue;
System.out.println(color);
return color;
}
}
*
*/
package utils;
/**
* @Title:RandomColor.java
* @Package: utils
* @Description:生成随机颜色
* @author:LJJ
* @date:2014-1-15 下午11:29:51
* @version V1.0
*/
import java.util.Random;
/**
*
* @author:LJJ
* @date:2014-1-15 下午11:29:51
* @version V1.0
*/
public class RandomColor {
public static String getColor() {
// 红色
String red;
// 绿色
String green;
// 蓝色
String blue;
// 生成随机对象
Random random = new Random();
// 生成红色颜色代码
red = Integer.toHexString(random.nextInt(256)).toUpperCase();
// 生成绿色颜色代码
green = Integer.toHexString(random.nextInt(256)).toUpperCase();
// 生成蓝色颜色代码
blue = Integer.toHexString(random.nextInt(256)).toUpperCase();
// 判断红色代码的位数
red = red.length() == 1 ? "0" + red : red;
// 判断绿色代码的位数
green = green.length() == 1 ? "0" + green : green;
// 判断蓝色代码的位数
blue = blue.length() == 1 ? "0" + blue : blue;
// 生成十六进制颜色值
String color = "#" + red + green + blue;
System.out.println(color);
return color;
}
}
0 0
- RandomColor
- randomColor(1)-- #e4393c类型
- randomColor (2)--rgb(r,g,b)类型
- VTK6.3+Qt5.4编译
- Android 多线程,线程池的使用
- PHP接口API文档转换SDK【适配CI框架】
- 循环单链表的实现,解决约瑟夫丢手帕问题
- poj 3041 Asteroids(二分图匹配匈牙利算法)
- RandomColor
- java在终端输入quit 后退出当前程序
- ORA-01157 ORA-01110
- jQuery设计思想
- 理解多层分布式架构、剖析webservice、remoting技术
- Migrations are pending. To resolve this issue, run: bin/rake db:migrate RAILS_ENV=development
- 数组共享双栈的实现
- jQuery基础语法
- lua table传值是传的引用