Skip to main content

HslColor Class

A color in the HSL (hue, saturation, lightness) color space.

Declaration

public final class HslColor extends Struct<HslColor> implements Cloneable, IEquatable<HslColor>

Implements

java.lang.Cloneable
com.devexpress.system.IEquatable<com.devexpress.docs.HslColor>

Inherited Members

com.devexpress.system.Struct.equals(java.lang.Object)
com.devexpress.system.Struct.getHashCode()
com.devexpress.system.Struct.hashCode()
java.lang.Object.clone()
java.lang.Object.finalize()
java.lang.Object.getClass()
java.lang.Object.notify()
java.lang.Object.notifyAll()
java.lang.Object.toString()
java.lang.Object.wait()
java.lang.Object.wait(long)
java.lang.Object.wait(long,int)

Inheritance

Object
com.devexpress.system.Struct
HslColor

Constructors

HslColor() Constructor

Initializes a new instance of the HslColor class.

Declaration

public HslColor()

HslColor(float hue, float saturation, float lightness) Constructor

Initializes a new instance of the HslColor class with specified normalized HSL color components.

Declaration

public HslColor(float hue, float saturation, float lightness)

Parameters

Name Type Description
hue float

The hue component as a normalized value between 0 and 1, where 1 corresponds to 360 degrees.

saturation float

The saturation component as a normalized value between 0 and 1.

lightness float

The lightness component as a normalized value between 0 and 1.

HslColor(HslColor other) Constructor

Initializes a new instance of the HslColor class with specified settings.

Declaration

public HslColor(HslColor other)

Parameters

Name Type Description
other HslColor

The HslColor instance to copy.

HslColor(int hue, int saturation, int lightness) Constructor

Initializes a new instance of the HslColor class with specified settings.

Declaration

public HslColor(int hue, int saturation, int lightness)

Parameters

Name Type Description
hue int

The hue value from 0 to 360000, where 360000 corresponds to 360 degrees.

saturation int

The saturation value from 0 to 100000, where 100000 corresponds to 100 percent.

lightness int

The lightness value from 0 to 100000, where 100000 corresponds to 100 percent.

Methods

applyHue(int value) Method

Applies the specified hue value to the color.

Declaration

public HslColor applyHue(int value)

Parameters

Name Type Description
value int

The hue value to apply. A value between 0 and 360.

Returns

Type Description
HslColor

The color with the applied hue.

applyHueMod(int value) Method

Modulates the color’s hue channel.

Declaration

public HslColor applyHueMod(int value)

Parameters

Name Type Description
value int

The hue modulation factor. A value between 0 and 100000, where 100000 represents no change.

Returns

Type Description
HslColor

The color with the applied hue modulation.

applyHueOffset(int value) Method

Applies a hue offset to the current color.

Declaration

public HslColor applyHueOffset(int value)

Parameters

Name Type Description
value int

The hue offset value. A value between -360 and 360.

Returns

Type Description
HslColor

The color with the applied hue offset.

applyLightness(int value) Method

Applies a lightness value to the current color.

Declaration

public HslColor applyLightness(int value)

Parameters

Name Type Description
value int

The lightness value to apply. A value between 0 and 100.

Returns

Type Description
HslColor

The color with the applied lightness.

applyLightnessMod(int value) Method

Applies a lightness modification to the current color.

Declaration

public HslColor applyLightnessMod(int value)

Parameters

Name Type Description
value int

The lightness modulation factor. A value between 0 and 100000, where 100000 represents no change.

Returns

Type Description
HslColor

The color with the applied lightness modification.

applyLightnessOffset(int value) Method

Applies a lightness offset to the current color.

Declaration

public HslColor applyLightnessOffset(int value)

Parameters

Name Type Description
value int

The lightness offset value. A value between -100 and 100.

Returns

Type Description
HslColor

The color with the applied lightness offset.

applySaturation(int value) Method

Applies a saturation value to the current color.

Declaration

public HslColor applySaturation(int value)

Parameters

Name Type Description
value int

The saturation value to apply. A value between 0 and 100.

Returns

Type Description
HslColor

The color with the applied saturation.

applySaturationMod(int value) Method

Applies a saturation modification to the current color.

Declaration

public HslColor applySaturationMod(int value)

Parameters

Name Type Description
value int

The saturation modulation factor. A value between 0 and 100000, where 100000 represents no change.

Returns

Type Description
HslColor

The color with the applied saturation modification.

applySaturationOffset(int value) Method

Applies a saturation offset to the current color.

Declaration

public HslColor applySaturationOffset(int value)

Parameters

Name Type Description
value int

The saturation offset value. A value between -100 and 100.

Returns

Type Description
HslColor

The color with the applied saturation offset.

applyTint(double tint) Method

Applies a tint to the current color.

Declaration

public HslColor applyTint(double tint)

Parameters

Name Type Description
tint double

The tint value to apply. A value between 0.0 and 1.0 (0.0 means no tint and 1.0 means full white).

Returns

Type Description
HslColor

The color with the applied tint.

clone() Method

Creates a copy of the current HslColor instance.

Declaration

public HslColor clone()

Returns

Type Description
HslColor

A new HslColor object that is a copy of the current instance.

equals(HslColor other) Method

Indicates whether the current HslColor object is equal to another object.

Declaration

public boolean equals(HslColor other)

Parameters

Name Type Description
other HslColor

The HslColor object to compare with the current object.

Returns

Type Description
boolean

true if the current object is equal to the other parameter; otherwise, false.

equals(Object obj) Method

Determines whether the specified object is equal to the current HslColor instance.

Declaration

public boolean equals(Object obj)

Parameters

Name Type Description
obj Object

The object to compare with the current HslColor instance.

Returns

Type Description
boolean

true if the specified object is equal to the current instance; otherwise, false.

fromRgb(Color color) Method

Converts a Color structure to an HslColor structure.

Declaration

public static HslColor fromRgb(Color color)

Parameters

Name Type Description
color Color

A Color structure to convert.

Returns

Type Description
HslColor

The conversion result.

getComplementColor() Method

Returns the complementary color of the current color.

Declaration

public HslColor getComplementColor()

Returns

Type Description
HslColor

The complementary color of the current color.

getDefaultValue() Method

Returns the default HSL color.

Declaration

public static HslColor getDefaultValue()

Returns

Type Description
HslColor

The default HSL color.

getFloatHue() Method

Returns the hue component of the color as a float value between 0 and 1.

Declaration

public float getFloatHue()

Returns

Type Description
float

The hue component of the color.

getFloatLightness() Method

Returns the lightness component of the color as a float value between 0 and 1.

Declaration

public float getFloatLightness()

Returns

Type Description
float

The lightness component of the color.

getFloatSaturation() Method

Returns the saturation component of the color as a float value between 0 and 1.

Declaration

public float getFloatSaturation()

Returns

Type Description
float

The saturation component of the color.

getHue() Method

Returns the hue component of the color as an integer value between 0 and 360.

Declaration

public int getHue()

Returns

Type Description
int

The hue component of the color.

getLightness() Method

Returns the lightness component of the color as an integer value between 0 and 100.

Declaration

public int getLightness()

Returns

Type Description
int

The lightness component of the color.

getSaturation() Method

Returns the saturation component of the color as an integer value between 0 and 100.

Declaration

public int getSaturation()

Returns

Type Description
int

The saturation component of the color.

hashCode() Method

The hash function for the current HslColor instance.

Declaration

public int hashCode()

Returns

Type Description
int

A hash code for the current HslColor instance.

setFloatHue(float value) Method

Sets the hue component of the color as a float value between 0 and 1.

Declaration

public void setFloatHue(float value)

Parameters

Name Type Description
value float

The hue component of the color.

setFloatLightness(float value) Method

Sets the lightness component of the color as a float value between 0 and 1.

Declaration

public void setFloatLightness(float value)

Parameters

Name Type Description
value float

The lightness component of the color.

setFloatSaturation(float value) Method

Sets the saturation component of the color as a float value between 0 and 1.

Declaration

public void setFloatSaturation(float value)

Parameters

Name Type Description
value float

The saturation component of the color.

setHue(int value) Method

Sets the hue component of the color as an integer value between 0 and 360.

Declaration

public void setHue(int value)

Parameters

Name Type Description
value int

The hue component of the color.

setLightness(int value) Method

Sets the lightness component of the color as an integer value between 0 and 100.

Declaration

public void setLightness(int value)

Parameters

Name Type Description
value int

The lightness component of the color.

setSaturation(int value) Method

Sets the saturation component of the color as an integer value between 0 and 100.

Declaration

public void setSaturation(int value)

Parameters

Name Type Description
value int

The saturation component of the color.

toRgb() Method

Converts the current HslColor structure to a Color structure.

Declaration

public Color toRgb()

Returns

Type Description
Color

The conversion result.