Android examples for Graphics:Color
morph Colors
//package com.java2s; import android.graphics.Color; import android.graphics.drawable.ColorDrawable; import android.graphics.drawable.TransitionDrawable; public class Main { public static TransitionDrawable morphColors(int fromColor, int toColor) { TransitionDrawable drawable = new TransitionDrawable( new ColorDrawable[] { new ColorDrawable(fromColor), new ColorDrawable(toColor) }); return drawable; }/*from w w w . j a v a2s. c o m*/ public static int morphColors(int fromColor, int toColor, float progress) { float[] fromHsv = new float[3]; float[] toHsv = new float[3]; Color.RGBToHSV(Color.red(fromColor), Color.green(fromColor), Color.blue(fromColor), fromHsv); Color.RGBToHSV(Color.red(toColor), Color.green(toColor), Color.blue(toColor), toHsv); float h = (toHsv[0] - fromHsv[0]) * progress; float s = (toHsv[1] - fromHsv[1]) * progress; float v = (toHsv[2] - fromHsv[2]) * progress; return Color.HSVToColor(new float[] { h, s, v }); } }