CoreMedia CKEditor 5 Plugins
    Preparing search index...

    Represents rgb() and rgba() color format as an immutable object.

    Note that browsers (just as JSDOM, CssStyle) parse colors to rgb() and rgba()

    Index

    Constructors

    • Constructor. Fails for invalid color components or alpha value.

      Parameters

      • red: number

        red component (integer 0 <= n <= 255)

      • green: number

        green component (integer 0 <= n <= 255)

      • blue: number

        blue component (integer 0 <= n <= 255)

      • Optionalalpha: number

        optional alpha (float 0.0 <= n <= 1.0)

      Returns RgbColor

    Properties

    alpha: number | undefined

    Get alpha, if set. The alpha range is from 0.0 to 1.0 including.

    blue: number

    Blue color component (0 to 255).

    colorName: string | undefined

    The W3C extended color name matching the given RGB value. undefined if RGB(A) cannot be represented as W3C extended color name.

    green: number

    Green color component (0 to 255).

    hasAlpha: boolean

    Signals, if any alpha channel has been set.

    hex: `#${string}`

    The color as hexadecimal representation such as #010aff.

    A possibly set alpha channel is ignored.

    hexa: `#${string}`

    The color as hexadecimal representation such as #010af0a0.

    An unset alpha will default to FF for full opacity.

    opaque: boolean

    Signals, if this color is opaque (no alpha or alpha = 1.0).

    red: number

    Red color component (0 to 255).

    rgb: `rgb(${string})`

    The color as rgb() representation.

    Any possibly set alpha channel is ignored.

    rgba: `rgba(${string})`

    The color as rgba() representation.

    An unset alpha will default to 1 for full opacity.

    Methods

    • Transforms the color to its rgb() or rgba() representation.

      Depending on if the alpha channel is set or not, uses representation as rgb or rgba.

      Returns `rgb(${string})` | `rgba(${string})`

    • Tries parsing the given string if it represents an rgb() or rgba() color code. If parsing is successful, returns RgbColor representation. undefined if it does not match and/or contains invalid parameters (such as color code components greater than 255).

      Parameters

      • value: string

        value to try to parse

      Returns RgbColor | undefined