Cocos Creator API

0.7.1

Cocos Creator is a highly customizable game development tool that utilizes the power of cocos2d-x.

Color

Extends ValueType
Module: cc

Representation of RGBA colors.

Each color component is a floating point value with a range from 0 to 1.

You can also use the convenience method <% crosslink cc.fireColor cc.fireColor %> to create a new Color.

Properties

WHITE Color static

BLACK Color static

TRANSPARENT Color static

GRAY Color static

RED Color static

GREEN Color static

BLUE Color static

YELLOW Color static

ORANGE Color static

CYAN Color static

MAGENTA Color static

There are no properties that match your current filter settings. You can change your filter settings in the index section on this page. index

Methods

clone ( ) Color

Clone a new color from the current color.

returns:

type: Color

Newly created color.

equals
(
  • other
)
Boolean

name type description
other Color

returns:

type: Boolean

lerp
(
  • to
  • ratio
  • [out ]
)
Color

name type description
to Color
ratio number

the interpolation coefficient.

out optional Color

optional, the receiving vector.

returns:

type: Color

toString ( ) String

returns:

type: String

setR
(
  • red
)
Color

name type description
red Number

the new Red component.

returns:

type: Color

this color.

setG
(
  • green
)
Color

name type description
green Number

the new Green component.

returns:

type: Color

this color.

setB
(
  • blue
)
Color

name type description
blue Number

the new Blue component.

returns:

type: Color

this color.

setA
(
  • alpha
)
Color

name type description
alpha Number

the new Alpha component.

returns:

type: Color

this color.

toCSS
(
  • opt
)
String

name type description
opt String

"rgba", "rgb", "#rgb" or "#rrggbb".

returns:

type: String

clamp ( )

Clamp this color to make all components between 0 to 1.

fromHEX
(
  • hexString
)
Color

name type description
hexString String

returns:

type: Color

toHEX
(
  • fmt
)
String

name type description
fmt String

"#rgb" or "#rrggbb".

returns:

type: String

toRGBValue ( ) Number

Convert to 24bit rgb value.

returns:

type: Number

fromHSV
(
  • h
  • s
  • v
)
Color

name type description
h Number
s Number
v Number

returns:

type: Color

toHSV ( ) Object

returns:

type: Object

{h: number, s: number, v: number}.

rgb2hsv
(
  • r
  • g
  • b
)
Object

name type description
r Number

red, must be [0, 255].

g Number

red, must be [0, 255].

b Number

red, must be [0, 255].

returns:

type: Object

{h: number, s: number, v: number}.

hsv2rgb
(
  • h
  • s
  • v
)
Object

name type description
h Number
s Number
v Number

returns:

type: Object

{r: number, g: number, b: number}}, rgb will be in [0, 255].

color
(
  • [r =0]
  • [g =0]
  • [b =0]
  • [a =255]
)
Color

The convenience method to create a new <% crosslink cc.Color color %> Alpha channel is optional. Default value is 255.

name type description
r optional Number 0
g optional Number 0
b optional Number 0
a optional Number 255

returns:

type: Color

colorEqual
(
  • color1
  • color2
)
Boolean

returns true if both ccColor3B are equal. Otherwise it returns false.

name type description
color1 Color
color2 Color

returns:

type: Boolean

true if both ccColor3B are equal. Otherwise it returns false.

hexToColor
(
  • hex
)
Color

convert a string of color for style to Color. e.g. "#ff06ff" to : cc.color(255,6,255)

name type description
hex String

returns:

type: Color

colorToHex
(
  • color
)
String

convert Color to a string of color for style. e.g. cc.color(255,6,255) to : "#ff06ff"

name type description
color Color

returns:

type: String

There are no methods that match your current filter settings. You can change your filter settings in the index section on this page. index