Change two colors by percentage
In Android, it is not good when most of the views has alpha value. Therefore, it is better by changing color of the view.
Below is the color interplation between a and b with given proportion:
Thanks to:
Below is the color interplation between a and b with given proportion:
private float interpolate(float a, float b, float proportion) { return (a + ((b - a) * proportion)); } /** Returns an interpoloated color, betweena
andb
*/ private int interpolateColor(int a, int b, float proportion) { float[] hsva = new float[3]; float[] hsvb = new float[3]; Color.colorToHSV(a, hsva); Color.colorToHSV(b, hsvb); for (int i = 0; i < 3; i++) { hsvb[i] = interpolate(hsva[i], hsvb[i], proportion); } return Color.HSVToColor(hsvb); }
Thanks to:
Comments
Post a Comment