Color

smile.colors.Color
See theColor companion class
object Color

Provides utility methods for creating and converting colors in various color spaces and formats, including HSI (Hue, Saturation, Intensity) and RGBA (Red, Green, Blue, Alpha). It also supports operations to lighten or darken colors.

Attributes

See also

java.awt.Color

Companion
class
Graph
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
Color.type

Members list

Type members

Inherited types

type MirroredElemLabels <: Tuple

The names of the product elements

The names of the product elements

Attributes

Inherited from:
Mirror
type MirroredLabel <: String

The name of the type

The name of the type

Attributes

Inherited from:
Mirror

Value members

Concrete methods

def argbIntFrom(red: Int, green: Int, blue: Int, opacity: Int): Int

Creates an ARGB integer value from RGBA components. Validates the RGBA components before conversion.

Creates an ARGB integer value from RGBA components. Validates the RGBA components before conversion.

Value parameters

blue

The blue component, in the range [0, 255].

green

The green component, in the range [0, 255].

opacity

The opacity component, in the range [0, 255]. Default is smile.infrastructure.Constants.MaximumOpacity.

red

The red component, in the range [0, 255].

Attributes

Returns

An integer representing the ARGB value.

def fromHSI(hue: Double, saturation: Double, intensity: Double, opacity: Int): Color

Creates a Color instance from HSI values with optional opacity. Validates the input values for HSI and opacity before conversion.

Creates a Color instance from HSI values with optional opacity. Validates the input values for HSI and opacity before conversion.

Value parameters

hue

The hue component of the color, in degrees [0, 360).

intensity

The intensity component of the color, in the range [0, 255].

opacity

The opacity of the color, in the range [0, 255]. Default is smile.infrastructure.Constants.MaximumOpacity.

saturation

The saturation component of the color, in the range [0, 1].

Attributes

Returns

A new Color instance based on the specified HSI values and opacity.

def fromRgbaInt(rgba: Int): Color
def hsiToRGB(hueInDegrees: Double, saturation: Double, intensity: Double): (Int, Int, Int)

Converts HSI values to RGB. Validates the input HSI values before conversion.

Converts HSI values to RGB. Validates the input HSI values before conversion.

Value parameters

hueInDegrees

The hue component of the color, in degrees [0, 360).

intensity

The intensity component of the color, in the range [0, 255].

saturation

The saturation component of the color, in the range [0, 1].

Attributes

Returns

A tuple containing the RGB components: (red, green, blue).

def isBlack(red: Int, green: Int, blue: Int): Boolean

Determines if the specified RGB color is black. A color is considered black if its red, green, and blue components are all at their minimum value.

Determines if the specified RGB color is black. A color is considered black if its red, green, and blue components are all at their minimum value.

Value parameters

blue

The blue component of the color, expected to be smile.infrastructure.Constants.MinimumBlue for black.

green

The green component of the color, expected to be smile.infrastructure.Constants.MinimumGreen for black.

red

The red component of the color, expected to be smile.infrastructure.Constants.MinimumRed for black.

Attributes

Returns

true if the color is black, otherwise false.

def isGray(red: Int, green: Int, blue: Int): Boolean

Determines if the specified RGB color is a shade of gray. A color is considered gray if its red, green, and blue components are equal.

Determines if the specified RGB color is a shade of gray. A color is considered gray if its red, green, and blue components are equal.

Value parameters

blue

The blue component of the color, in the range [0, 255].

green

The green component of the color, in the range [0, 255].

red

The red component of the color, in the range [0, 255].

Attributes

Returns

true if the color is a shade of gray, otherwise false.

def rgbToHSI(red: Int, green: Int, blue: Int): (Double, Double, Double)

Converts RGB values to HSI (Hue, Saturation, Intensity). Validates the input RGB values before conversion.

Converts RGB values to HSI (Hue, Saturation, Intensity). Validates the input RGB values before conversion.

Value parameters

blue

The blue component, in the range [0, 255].

green

The green component, in the range [0, 255].

red

The red component, in the range [0, 255].

Attributes

Returns

A tuple containing the HSI components: (hue, saturation, intensity).

def rgbaIntFrom(red: Int, green: Int, blue: Int, opacity: Int): Int