Skip to content
y-lohse edited this page Dec 29, 2012 · 6 revisions

Cannon.Misc.color instances are objects that represent a simple color. The main advantage is that you can modify any of the red, green, blue or alpha values easily and independently. They are supported all accross the framework, so you can seamlessly use them as values for fillStyle or strokeStyle for example.

Properties

r:Integer

Red value, between 0 and 255. Default is 0.

g:Integer

Green value, between 0 and 255. Default is 0.

b:Integer

Blue value, between 0 and 255. Default is 0.

a:Float

Alpha value, between 0 and 1. Default is 1.

Static functions

parsable:Boolean

Parameters

  • s:String : string to check

Description

Checks if the provided string matches any of the supported color formats. Those are

  • rgba(r, g, b, a)
  • rgb(r, g, b)
  • #000
  • #000000

Functions

__construct:Cannon.Misc.Color

Parameters #1

  • r:Integer
  • g:Integer
  • b:Integer
  • a:Float : optionnal

Parameters #2

  • color:String : can be a 3 or 6 digit hexadecimal number, a rgba() representation of a color or a rgb() representation of a color.

Description

Creates a new Color.

generate:String

Description

Converts the Cannon.Misc.Color into a plain text rgba value.