Inherits from JavaScript Object
Location aphid.core.Color

Overview

Represents a color with red, green, blue and alpha components.

Color is a special data type for attributes and parameters in OpenAphid. Besides an instance of the Color class, string and int values are also valid for attributes and parameters, which are declared to be the type of Color.

For example, the statements below are all valid to set red color to a Sprite.

sprite.color = new Color(255, 0, 0);

sprite.color = "red";

sprite.color = 0xff0000; //RGB color

Please refer to the W3C document of Extended color keywords to get the list of valid color names.

Overview of Constructors

Overview of Tasks

Attributes

  • Name
  • a

    Alpha component

  • b

    Blue component

  • g

    Green component

  • r

    Red component

  • Type
  • int
  • int
  • int
  • int
  • Writability
  • readonly
  • readonly
  • readonly
  • readonly

Functions

  • Return Type
  • string

Constructors

Color(color, [a])

new Color(color color, [int a])

Parameters

Non-null color color
Optional int a

Color(r, g, b, [a])

new Color(int r, int g, int b, [int a])

Parameters

int r
int g
int b
Optional int a

Discussion

Constructs a color. Each component should be an int in the range of [0, 255]

Attributes

a

Alpha component

readonly int a

b

Blue component

readonly int b

g

Green component

readonly int g

r

Red component

readonly int r

Functions

toString()

string toString()

Return Value: string