Color

open class Color @JvmOverloads constructor(var red: Float, var green: Float, var blue: Float, var alpha: Float = 1.0f)

Color with red, green, blue and alpha components. Each RGB component is a number between 0.0 and 1.0 indicating the component's intensity. The alpha component is a number between 0.0 (fully transparent) and 1.0 (fully opaque) indicating the color's opacity.

Constructors

Link copied to clipboard
constructor(red: Float, green: Float, blue: Float, alpha: Float = 1.0f)
constructor()

Constructs a color with red, green, blue and alpha all 1.0.

constructor(red: Int, green: Int, blue: Int, alpha: Int = 255)

Constructs a color from integer components

constructor(colorInt: Int)

Constructs a color with components stored in a color int. Color ints are stored as packed ints as follows: (alpha << 24) | (red << 16) | (green << 8) | (blue). Each component is an 8 bit number between 0 and 255 with 0 indicating the component's intensity.

constructor(color: Color)

Constructs a color with the components of a specified color.

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard

The color's alpha component.

Link copied to clipboard
var blue: Float

The color's blue component.

Link copied to clipboard

The color's green component.

Link copied to clipboard
var red: Float

The color's red component.

Functions

Link copied to clipboard
fun copy(color: Color): Color

Sets this color to the components of a specified color.

Link copied to clipboard
open operator override fun equals(other: Any?): Boolean
Link copied to clipboard
open override fun hashCode(): Int
Link copied to clipboard

Premultiplies this color in place. The RGB components are multiplied by the alpha component.

Link copied to clipboard

Premultiplies the specified color and stores the result in this color. This color's RGB components are set to the product of the specified color's RGB components and its alpha component. This color's alpha component is set to the specified color's alpha.

Link copied to clipboard

Copies this color's premultiplied components to the specified array. The result is compatible with GLSL uniform vectors, and can be passed to the function glUniform4fv.

Link copied to clipboard
fun set(colorInt: Int): Color

Sets this color to the components stored in a color int. Color ints are stored as packed ints as follows: (alpha << 24) | (red << 16) | (green << 8) | (blue). Each component is an 8 bit number between 0 and 255 with 0 indicating the component's intensity.

fun set(red: Float, green: Float, blue: Float, alpha: Float): Color

Sets this color to the specified components.

Link copied to clipboard
fun toArray(result: FloatArray, offset: Int): FloatArray

Copies this color's components to the specified array. The result is compatible with GLSL uniform vectors, and can be passed to the function glUniform4fv.

Link copied to clipboard

Returns a string representation of this color, indicating the byte values corresponding to this color's floating-point component values.

Link copied to clipboard

Returns this color's components as a color int. Color ints are stored as packed ints as follows: `(alpha <<

Link copied to clipboard
fun toContrastColor(threshold: Int = 75): Color

Determine contrast background color for any input color

Link copied to clipboard

Create a rgba color string that conforms to CSS Color Module Level 3 specification.

Link copied to clipboard
fun toHexString(isUsingAlpha: Boolean = false, argb: Boolean = false): String

Create a hex color string that CSS can use. Optionally, inhibit capturing alpha, because some uses reject a four-component color specification.

Link copied to clipboard
fun toHSV(hsv: FloatArray)

Convert the argb color to its HSV components. hsv0 is Hue [0 .. 360) hsv1 is Saturation 0...1 hsv2 is Value 0...1

Link copied to clipboard
open override fun toString(): String