Package org.oscim.utils
Class ColorUtil
java.lang.Object
org.oscim.utils.ColorUtil
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic intblend(int color1, int color2, float mix) Blend two colors.static intdesaturate(int color) static inthslToRgb(double h, double s, double l) static intConverts an HSL color value to RGB.static inthsvToRgb(double h, double s, double v) static intConverts an HSV color value to RGB.static intmodHsv(int color, double hue, double saturation, double value, boolean relative) static Vec3rgbToHsl(double r, double g, double b) static Vec3Converts an RGB color value to HSL.static Vec3rgbToHsv(double r, double g, double b) static Vec3Converts an RGB color value to HSV.static intsaturate(int color, double saturation) static intsaturate(int color, double saturation, boolean relative) static intsetHue(int color, double hue) static intshiftHue(int color, double hue)
-
Constructor Details
-
ColorUtil
public ColorUtil()
-
-
Method Details
-
desaturate
public static int desaturate(int color) -
saturate
public static int saturate(int color, double saturation) -
setHue
public static int setHue(int color, double hue) -
shiftHue
public static int shiftHue(int color, double hue) -
saturate
public static int saturate(int color, double saturation, boolean relative) -
modHsv
public static int modHsv(int color, double hue, double saturation, double value, boolean relative) - Parameters:
hue- the hue from 0 to 1 (exclusive) 0: no color shift 0.5: opposite huesaturation- the saturation 0 to 1: desaturate 1 to 2: saturatevalue- the lightness 0 to 1: darken 1 to 2: lightenrelative- indicate if colors are modified relative to their values (e.g black not changes if relative)
-
rgbToHsl
Converts an RGB color value to HSL. Conversion formula adapted from http://en.wikipedia.org/wiki/HSL_color_space. Assumes r, g, and b are contained in the set [0, 255] and returns h, s, and l in the set [0, 1].- Parameters:
Number- r The red color valueNumber- g The green color valueNumber- b The blue color value- Returns:
- Array The HSL representation
-
rgbToHsl
-
hslToRgb
Converts an HSL color value to RGB. Conversion formula adapted from http://en.wikipedia.org/wiki/HSL_color_space. Assumes h, s, and l are contained in the set [0, 1] and returns r, g, and b in the set [0, 255].- Parameters:
Number- h The hueNumber- s The saturationNumber- l The lightness- Returns:
- Array The RGB representation
-
rgbToHsv
Converts an RGB color value to HSV. Conversion formula adapted from http://en.wikipedia.org/wiki/HSV_color_space. Assumes r, g, and b are contained in the set [0, 255] and returns h, s, and v in the set [0, 1].- Parameters:
Number- r The red color valueNumber- g The green color valueNumber- b The blue color value- Returns:
- Array The HSV representation
-
rgbToHsv
-
hsvToRgb
Converts an HSV color value to RGB. Conversion formula adapted from http://en.wikipedia.org/wiki/HSV_color_space. Assumes h, s, and v are contained in the set [0, 1] and returns r, g, and b in the set [0, 255].- Parameters:
h- The hues- The saturationv- The valueout- result rgb, may be ommited- Returns:
- Array The RGB representation
-
hsvToRgb
public static int hsvToRgb(double h, double s, double v) -
hslToRgb
public static int hslToRgb(double h, double s, double l) -
blend
public static int blend(int color1, int color2, float mix) Blend two colors.- Parameters:
color1- the first colorcolor2- the second colormix- the mixing proportion in range 0 to 1- Returns:
- the blended color
-