🌈 Create new beautiful Compose Gradients with our new wesite ->
Function

Color

Create a Color by passing individual red, green, blue, alpha, and colorSpace components.

Color

Source set: Common
public fun Color(
    red: Float,
    green: Float,
    blue: Float,
    alpha: Float = 1f,
    colorSpace: ColorSpace = ColorSpaces.Srgb,
): Color

Create a Color by passing individual red, green, blue, alpha, and colorSpace components. The default color space is sRGB and the default alpha is 1.0 (opaque).

If the red, green, or blue values are outside of the range defined by colorSpace (see ColorSpace.getMinValue and ColorSpace.getMaxValue, these values get clamped appropriately to be within range.

Throws: IllegalArgumentException

If colorSpace does not have ColorSpace.componentCount equal to 3.

Throws: IllegalArgumentException

If colorSpace has an ColorSpace.id set to ColorSpace.MinId.

Color

Source set: Common
public fun Color(@ColorInt color: Int): Color

Creates a new Color instance from an ARGB color int. The resulting color is in the sRGB color space.

Parameters

color The ARGB color int to create a Color from.

Return

A non-null instance of {@link Color}

Color

Source set: Common
public fun Color(color: Long): Color

Creates a new Color instance from an ARGB color int. The resulting color is in the sRGB color space. This is useful for specifying colors with alpha greater than 0x80 in numeric form without using Long.toInt:

val color = Color(0xFF000080)

Parameters

color The 32-bit ARGB color int to create a Color from

Return

A non-null instance of {@link Color}

Color

Source set: Common
public fun Color(
    @IntRange(from = 0, to = 0xFF) red: Int,
    @IntRange(from = 0, to = 0xFF) green: Int,
    @IntRange(from = 0, to = 0xFF) blue: Int,
    @IntRange(from = 0, to = 0xFF) alpha: Int = 0xFF,
): Color

Creates a new Color instance from an ARGB color components. The resulting color is in the sRGB color space. The default alpha value is 0xFF (opaque).

Parameters

red The red component of the color, between 0 and 255.
green The green component of the color, between 0 and 255.
blue The blue component of the color, between 0 and 255.
alpha The alpha component of the color, between 0 and 255.

Return

A non-null instance of {@link Color}