Android examples for Graphics:Color Operation
Gets the matching colors for the color provided
import android.graphics.Color; import android.graphics.drawable.ColorDrawable; import android.os.Build; import android.view.View; import java.lang.reflect.Field; public class Main{ /**/*from w ww .ja v a 2 s.c om*/ * Gets the matching colors for the color provided * @param color * @return */ public static int[] getTetradColorPallet(int color) { int[] shiftedColors = new int[3]; shiftedColors[0] = shiftColorHue(color, 45f); shiftedColors[1] = shiftColorHue(color, 180f); shiftedColors[2] = shiftColorHue(color, 225f); return shiftedColors; } /** * Shifts the hue by the offset specified * @param color * @param offset * @return shifted color */ public static int shiftColorHue(int color, float offset) { float[] colorShiftHSV = new float[3]; Color.colorToHSV(color, colorShiftHSV); colorShiftHSV[0] = (colorShiftHSV[0] + offset) % 360; return Color.HSVToColor(colorShiftHSV); } }