This repository has been archived on 2022-08-05. You can view files and clone it, but cannot push or open issues or pull requests.
school-projects/src/main/java/io/gitlab/jfronny/ImgJava/util/HSB.java

32 lines
835 B
Java

package io.gitlab.jfronny.ImgJava.util;
import java.awt.*;
/**
* Write a description of class PixelColor here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class HSB {
public static double getHue(Color c) {
float[] hsb = Color.RGBtoHSB(c.getRed(), c.getGreen(), c.getBlue(), null);
return hsb[0];
}
public static double getSaturation(Color c) {
float[] hsb = Color.RGBtoHSB(c.getRed(), c.getGreen(), c.getBlue(), null);
return hsb[1];
}
public static double getBrightness(Color c) {
float[] hsb = Color.RGBtoHSB(c.getRed(), c.getGreen(), c.getBlue(), null);
return hsb[2];
}
public static Color getColor(double h, double s, double b) {
return new Color(Color.HSBtoRGB((float) h, (float) s, (float) b));
}
}