ComPDFKit Web SDK
    Preparing search index...

    Class Color

    An RGBA color.

    Index
    A B G R
    • Numbers are R G B (0–255) and A (0–1); also accepts another color (copied), an array of 0–1 components (1 gray, 3 RGB, 4 CMYK), or '#rrggbb'. Note: with no arguments it is opaque black.

      Parameters

      • Optionalr: number | ColorInput
      • Optionalg: number
      • Optionalb: number
      • Optionala: number

      Returns Color

      const { Annotations } = instance.Core;
      const red = new Annotations.Color(255, 0, 0);
      const halfTransparentBlue = new Annotations.Color(0, 0, 255, 0.5);
      const fromHex = new Annotations.Color('#00aa55');
      console.log(fromHex.toHexString()); // '#00aa55'
    • Converts the color to a hex string (alpha is ignored).

      Returns string

      The color as '#rrggbb'.

    • CSS color string rgba(R,G,B,A).

      Returns string

    A: number

    Alpha (opacity), 0 to 1.

    B: number

    Blue component, 0 to 255.

    G: number

    Green component, 0 to 255.

    R: number

    Red component, 0 to 255.