Java Graphics Rotate rotateHue(Color color, float fraction)

Here you can find the source of rotateHue(Color color, float fraction)

Description

rotate Hue

License

GNU General Public License

Declaration

public static Color rotateHue(Color color, float fraction) 

Method Source Code


//package com.java2s;
/*/*  w w  w . j a  v a2s. c  o m*/
 *                    BioJava development code
 *
 * This code may be freely distributed and modified under the
 * terms of the GNU Lesser General Public Licence.  This should
 * be distributed with the code.  If you do not have a copy,
 * see:
 *
 *      http://www.gnu.org/copyleft/lesser.html
 *
 * Copyright for this code is held jointly by the individual
 * authors.  These should be listed in @author doc comments.
 *
 * For more information on the BioJava project and its aims,
 * or to join the biojava-l mailing list, visit the home page
 * at:
 *
 *      http://www.biojava.org/
 *
 * Created on May 20, 2010
 * Author: Andreas Prlic 
 *
 */

import java.awt.Color;

public class Main {
    public static Color rotateHue(Color color, float fraction) {

        float af[] = Color.RGBtoHSB(color.getRed(), color.getGreen(), color.getBlue(), null);

        float hue = af[0];
        float saturation = af[1];
        float brightness = af[2];

        //System.out.println(hue + " " + saturation + " " + brightness);

        float hueNew = hue + fraction;

        //System.out.println(hue + " " + hueNew);

        if (hueNew > 1) {
            hueNew = hueNew - 1;
        }

        return Color.getHSBColor(hueNew, saturation, brightness);
    }
}

Related

  1. rotateBy(Vector points, double theta, Vector newPoints)
  2. rotateByAngle(final Point2D pos, final Point2D center, final double angle)
  3. rotateClockwise(Path source, Path target)
  4. rotateCoor(float x, float y, float theta)
  5. rotateCoorAroundPoint(float x, float y, float xctr, float yctr, float theta)
  6. rotateHue(Color color, float fraction)
  7. rotateMoveClockwise(Point move, int size)
  8. rotatePoint(double x0, double y0, double x, double y, double a)
  9. rotatePoint(double x0, double y0, double x, double y, double angle)