Color.darken

Syntax

darken(alpha)

Parameters

alpha. Transparency, may take values from 0 to 1.

Description

The darken method darkens color for the specified transparency value.

Comments

The method reduces color value, color transparency does not change.

Example

To execute the example the HTML page must contain the ColorCombo component named colCombo (see Example of Creating the ColorCombo Component). Reduce saturation of the color selected in the drop-down list by 50%:

// Get the color selected in the drop-down list
var color = colCombo.getColor();
// Output color value to the console
JSON.stringify(color, null, 2);
// Darken the color
color.darken(0.5);
// Apply the changed color
colCombo.setColor(color);
// Output color value to the console
JSON.stringify(color, null, 2);

After executing the example the color selected in the drop-down list is darkened by 50%. The console displays color settings before darkening:

{
  "_A": 255,
  "_H": 0,
  "_S": 100,
  "_V": 100,
  "_R": 255,
  "_G": 0,
  "_B": 0
}

And after darkening:

{
  "_A": 255,
  "_H": 0,
  "_S": 100,
  "_V": 50,
  "_R": 128,
  "_G": 0,
  "_B": 0
}

See also:

Color