Skip to content

Latest commit

 

History

History
202 lines (149 loc) · 3.39 KB

color.md

File metadata and controls

202 lines (149 loc) · 3.39 KB

API Documentation for Color

NoPoDoFo Color

The Color class represents all color formats supported by NoPoDoFo. All color values must be between 0.0 and 1.0

class Color {
		constructor()
		constructor(grey: number)
		constructor(fromString: string)
		constructor(red: number, green: number, blue: number)
		constructor(cyan: number, magenta: number, yellow: number, black: number)
    getColorStreamString(): string
		isRGB(): boolean
    isCMYK(): boolean
    isGreyScale(): boolean
    convertToGreyScale(): Color
    convertToCMYK(): Color
    convertToRGB(): Color
    getGrey(): number
    getRed(): number
    getGreen(): number
    getBlue(): number
    getCyan(): number
    getMagenta(): number
    getYellow(): number
    getBlack(): number
}

Constructors


const color = new nopodofo.Color('magenta')

Create a color from a string. Valid string arguments are:

  • single grey value, e.g. '0.5'
  • named color, e.g. 'aquamarine'
  • hex value, e.g. '#FF002A'

If the argument passed could not be parsed, Black is returned.

constructor(grey: number)

Create a new GreyScale Color

constructor(red:number, green: number, blue: number)

Create a new RGB Color

constructor(cyan: number, magenta: number, yellow: number, black: number)

Create a new CMYK Color

Properties


Methods


getColorStreamString

getColorStreamString()

Get the stream representation of this color. For use when writing directly to a PdfStream, such as a PdfField AppearanceStream.

isRGB

isRGB(): boolean

Is the color in RGB format

isCMYK

isCMYK(): boolean

Is the color in CMYK format

isGreyScale

isGreyScale(): boolean

Is the color in GreyScale format

convertToGreyScale

convertToGreyScale(): Color

Get the current color converted to GreyScale

convertToCMYK

convertToCMYK(): Color

Get the current color converted to CMYK

convertToRGB

convertToRGB(): Color

Get the current color converted to RGB

getGrey

getGrey(): number

Get grey value

getRed

getRed(): number

Get red value

getGreen

getGreen(): number

Get green value

getBlue

getBlue(): number

Get blue value

getCyan

getCyan(): number

Get cyan value

getMagenta

getMagenta(): number

Get magenta value

getYellow

getYellow(): number

Get yellow value

getBlack

getBlack(): number

Get black value