Java 如何调整色码的色调?
也许有人知道Java(Android)中一种将色调应用于颜色代码的方法Java 如何调整色码的色调?,java,android,Java,Android,也许有人知道Java(Android)中一种将色调应用于颜色代码的方法 例如,如果我有#1589FF并应用180色调,我应该得到#FF8B14。这应该可以做到: Color c = new Color(0x15, 0x89, 0xFF); // Get saturation and brightness. float[] hsbVals = new float[3]; Color.RGBtoHSB(c.getRed(), c.getGreen(), c.getBlue(), hsbVals);
例如,如果我有#1589FF并应用180色调,我应该得到#FF8B14。这应该可以做到:
Color c = new Color(0x15, 0x89, 0xFF);
// Get saturation and brightness.
float[] hsbVals = new float[3];
Color.RGBtoHSB(c.getRed(), c.getGreen(), c.getBlue(), hsbVals);
// Pass .5 (= 180 degrees) as HUE
c = new Color(Color.HSBtoRGB(0.5f, hsbVals[1], hsbVals[2]));
这是另一个很好的方法
/**
* @param color the ARGB color to convert. The alpha component is ignored
* @param hueFactor The factor of hue, an int [0 .. 360)
* @return new color with the specified hue.
*/
public int hue(int color, int hueFactor) {
float[] hsl= new float[3];
ColorUtils.colorToHSL(color,hsl);
hsl[0]=hueFactor;
return ColorUtils.HSLToColor(hsl);
}
@也许这是个很无聊的问题,但0.5是180吗?公式是什么?@VijayC,.5*360度=180度。@theficster510,
新颜色(yourInt)
。