Shifts the hsv of the color - Android Graphics

Android examples for Graphics:Color Operation

Description

Shifts the hsv of the color

Demo Code


//package com.java2s;
import android.graphics.Color;

public class Main {
    /**//  w w  w. j av  a2 s.c  o m
     * Shifts the hsv of the color
     * @param color
     * @param offsetHue
     * @param offsetSaturation
     * @param offsetValue
     * @return shifted color
     */
    public static int shiftColorHSV(int color, float offsetHue,
            float offsetSaturation, float offsetValue) {
        float[] colorShiftHSV = new float[3];
        Color.colorToHSV(color, colorShiftHSV);

        colorShiftHSV[0] = (colorShiftHSV[0] + offsetHue) % 360;
        colorShiftHSV[1] = colorShiftHSV[1] + offsetSaturation;
        colorShiftHSV[2] = colorShiftHSV[2] + offsetValue;

        return Color.HSVToColor(colorShiftHSV);
    }
}

Related Tutorials