darken color

Prev Next

Function Names

darken color

Library

Style Library

Description

This function derives a darkened shade of a specified color

Call as: function

Restrictions

Don't forget to include 'Style Library' at the top of your program

Parameter count

2

Parameters

No.TypeDescription
1.
input
set
string
Color

Three possibiltes to specify the color:

  • As RGB in a set containing 3 numbers (0..255). Example: { 255, 128, 64 }
  • Existing color name. Example: red, blue, navy, ecru
  • Hexadecimal code: '#' followed by 6 hexdecimal digits. Example: #FF8040

2.
input
numeral Darkening down factor

e.g. factor 2 is the color precisely between white and specified color
Example: mandarin {255,128,0} translates to {128,64,0}
Use lower factors (e.g. 1.5) for less lighter shades, and bigger factors (e.g. 4) for significantly lighter shades.

Return value

TypeDescription
set RGB color

The color is specified in a set containing 3 numbers (0..255).

Examples

       for (i[] = 1, i[] <4, i[]++)
       {
           echo( new line, "Factor ", i[],":" );
           echo( "  Orange: ", darken color( orange, i[] ));
           echo( "  Navy:   ", darken color( {0,0,128}, i[] ));
           echo( "  Teal:   ", darken color( "#008080", i[] ));
       }

Output

Factor 1:
  Orange: {255,192,0}
  Navy:   {0,0,128}
  Teal:   {0,128,128}

Factor 2:
  Orange: {128,96,0}
  Navy:   {0,0,64}
  Teal:   {0,64,64}

Factor 3:
  Orange: {85,64,0}
  Navy:   {0,0,43}
  Teal:   {0,43,43}
Try it yourself: Open LIB_Function_darken_color.b4p in B4P_Examples.zip. Decompress before use.

See also

darken colors
lighten color
weaken color