Function

color

(r: number, g: number, b: number): ColorComp

Sets the color of a Game Object (rgb 0-255).

param r- The red value to set.

param g- The green value to set.

param b- The blue value to set.

// blue frog
add([
    sprite("bean"),
    color(0, 0, 255),
]);

returns The color comp.

since v2000.0

group Components

subgroup Rendering

Function

color

(c: Color): ColorComp

Sets the color of a Game Object using a previously created Color Object.

param c- The color to clone and set.

// blue frog
const blue = rgb(0, 0, 255);

add([
    sprite("bean"),
    color(blue),
]);

returns The color comp.

since v2000.0

group Components

subgroup Rendering

Function

color

(rgb: [number, number, number]): ColorComp

Sets the color of a Game Object using an array (rgb 0-255).

param rgb- The color array to set [r, g, b].

// blue frog
add([
    sprite("bean"),
    color([0, 0, 255]),
]);

returns The color comp.

since v2000.0

group Components

subgroup Rendering

Function

color

(c: OptionalString<CSSColorKeywords>): ColorComp

Sets the color of a Game Object using a CSS color keywords or hexadecimal string.

param c- The CSS color keyword or hexadecimal code to set.

// blue frog (HEX)
add([
    sprite("bean"),
    color("#0000ff"),
]);

// red cheese (CSS)
add([
    sprite("mark"),
    color("red"),
]);

returns The color comp.

since v2000.0

group Components

subgroup Rendering

Function

color

(c: number): ColorComp

Sets the color of a Game Object using a hexadecimal literal number.

param c- The hexadecimal literal number.

// blue frog
add([
    sprite("bean"),
    color(0x0000ff),
]);

returns The color comp.

since v2000.0

group Components

subgroup Rendering

Function

color

(): ColorComp

Sets the color of a Game Object to white (no effect).

// normal frog
add([
    sprite("bean"),
    color(),
]);

returns The color comp.

since v2000.0

group Components

subgroup Rendering

kaplay logo

Components

Miscalenous