Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Spectra

颜色对象,rgb使用0-255,a使用0-1 改造自:https://github.com/avp/spectra

export

Hierarchy

  • Spectra

Index

Constructors

  • 构建Spectra颜色

    Parameters

    • arg: any

      构建参数 支持css {r:number,g:number,b:number,a?:number} {red:number,green:number,blue:number,alplh?:number} [255,255,255,1]

    Returns Spectra

Properties

toJSON: (() => string)

Type declaration

    • (): string
    • Returns string

toString: (() => string)

Type declaration

    • (): string
    • Returns string

Methods

  • alpha(arg?: any): any
  • 获取或者设置alpha分量

    Parameters

    • Optional arg: any

      分量值

    Returns any

    分量值

  • blue(arg?: any): any
  • 获取或设置蓝色值

    Parameters

    • Optional arg: any

      蓝色值

    Returns any

    蓝色值

  • Returns the complement of this color.

    Returns Spectra

  • contrast(other: any): number
  • Returns a number from 0 to 1 representing the color contrast between the two colors.

    Parameters

    • other: any

    Returns number

  • Darkens a color based on percentage value from 1 to 100.

    Parameters

    • percentage: any

    Returns Spectra

  • desaturate(percentage: any): Spectra
  • Desaturates the color based on a percentage value.

    Parameters

    • percentage: any

    Returns Spectra

  • equals(other: any): boolean
  • Tests to see if this color is equal to other. Because other is also a color, it follows that we can simply compare red, green, blue, and alpha to see if the colors are equal.

    Parameters

    • other: any

    Returns boolean

  • Fades in the current color based on a percentage value, making it less transparent.

    Parameters

    • percentage: any

    Returns Spectra

  • Fades out the current color based on a percentage value, making it less transparent.

    Parameters

    • percentage: any

    Returns Spectra

  • getColor(): { a: number; b: number; b1: number; g: number; g1: number; r: number; r1: number }
  • Returns { a: number; b: number; b1: number; g: number; g1: number; r: number; r1: number }

    • a: number
    • b: number
    • b1: number
    • g: number
    • g1: number
    • r: number
    • r1: number
  • glNumberArray(): any[]
  • 获取[0-1]范围的gl颜色数组

    Returns any[]

    范围的gl颜色数组

  • gradient(other: any, n: any): any[]
  • Returns a gradient of colors approximately from this color to the other, consisting of n colors.

    Parameters

    • other: any
    • n: any

    Returns any[]

  • Returns a Spectra object, which is the grayscale of the current color.

    Returns Spectra

  • green(arg?: any): any
  • 获取或设置绿色值

    Parameters

    • Optional arg: any

      绿色值

    Returns any

    绿色值

  • harmony(type: any, index: any): any[]
  • Harmony

    desc

    Returns an array of harmonious colors (goo.gl/R3FRlU).

    author

    Benjamin Fleming (benjamminf)

    since

    2014-01-06

    Parameters

    • type: any

      (string) - Type of harmony.

    • index: any

      (int) - At which point the original color exists on the set harmonies. Since some types of color harmonies have inconsistent offsets (eg. rectangle) it's useful to note where this original color lies on the set harmony hues.

    Returns any[]

    Array of Spectra instances.

  • hex(): string
  • 获取#开头的十六进制字符串

    Returns string

    十六进制字符串

  • hexNumber(): any
  • 获取十六进制字符串

    Returns any

    0x开头的十六进制字符串

  • hexWidthAlpha(): string
  • 获取带透明度的十六进制字符串

    Returns string

    十六进制字符串

  • hslString(): string
  • 获取hsl字符串

    Returns string

    hsl字符串

  • hslaString(): string
  • 获取hsla字符串

    Returns string

    hsla字符串

  • hue(arg?: any): any
  • 获取或者设置hsv的分量

    Parameters

    • Optional arg: any

      分量值

    Returns any

    分量值

  • isDark(): boolean
  • isLight(): boolean
  • If a color is light then it's best to have black text on it.

    Returns boolean

  • labObject(): any
  • 获取lab对象

    Returns any

    lab对象

  • Lightens a color based on percentage value from 1 to 100.

    Parameters

    • percentage: any

    Returns Spectra

  • lightness(arg?: any): any
  • 获取或者设置hsl的l分量

    Parameters

    • Optional arg: any

      分量值

    Returns any

    分量值

  • luma(): number
  • Calculates the luma of the color, i.e. how it appears on screen.

    Returns number

  • mix(other: any, percentage: any): Spectra
  • Returns the color that results from mixing percent of the other color into this color.

    Parameters

    • other: any
    • percentage: any

    Returns Spectra

  • near(other: any, percentage: any): boolean
  • Tests to see if an other color is within a percentage range of this color.

    Parameters

    • other: any
    • percentage: any

    Returns boolean

  • Negates this color. For a color {R, G, B}, returns a new color {R', G', B'}, where R' = 255 - R and so on.

    Returns Spectra

  • randomColorRange(percentage: any): Spectra
  • Lightens or darkens a color based on a random value in the specified range. Percentage should be passed in as an integer, so 40 would lighten or darken up to 40%.

    Parameters

    • percentage: any

    Returns Spectra

  • red(arg?: any): any
  • 获取或设置红色值

    Parameters

    • Optional arg: any

      颜色值

    Returns any

  • rgbNumber(): number
  • 获取rgb数字

    Returns number

    rgb数字

  • rgbaString(): string
  • 获取rgba字符串

    Returns string

    rgba字符串

  • Adds saturation to the color based on a percentage value.

    Parameters

    • percentage: any

    Returns Spectra

  • saturation(arg?: any): any
  • 获取或者设置hsl的s分量

    Parameters

    • Optional arg: any

      分量值

    Returns any

    分量值

  • saturationv(arg?: any): any
  • 获取或者设置hsv的s分量值

    Parameters

    • Optional arg: any

      分量值

    Returns any

    分量值

  • value(arg?: any): any
  • 获取或者设置hsv的v分量

    Parameters

    • Optional arg: any

      分量值

    Returns any

    分量值

  • Generates a random color.

    Returns Spectra

Generated using TypeDoc