darken colors

Prev Next

Function Names

darken colors

Library

Style Library

Description

This function Derives darkened shades of selected colors in the color palette.

Call as: procedure

Restrictions

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

Parameter count

3

Parameters

No.TypeDescription
1.
input
numeral
set
Row numbers

Specify one or multiple table row numbers in the table 'global color table'. The colors specified in the corresponding row will be darkened.
Hint: Use table selected rows() to select table rows by contents in the table..

2.
input
numeral or string Suffix

Specify a suffix to be added to the color names in order to distinguish them from their original colors.

3.
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 darker shades, and bigger factors (e.g. 4) for significantly darker shades.

Examples


       darken colors( table selected rows( global color table, [Cat 2]==primary), X, 5 );

       table copy table selected rows( global color table, t, [Cat 2]==primary );

       table list ( t );
       table process( t, table style rows( t, row(), table, fill color, [Color Name], text color, white ) );

       table save( t, "Images/Style_Darkened_Colors.html", HTML );
       table save( t, "Images/Style_Darkened_Colors.xls", EXCEL );
       table save excel file( t, Contents, "Images/Style_Darkened_Colors.xlsx" );

Output

    0 : Color Name     | Cat 1    | Cat 2   | Red | Green | Blue | HTML Color
    1 : red            | standard | primary | 255 | 0     | 0    | #FF0000   
    2 : yellow         | standard | primary | 255 | 255   | 0    | #FFFF00   
    3 : green          | standard | primary | 0   | 255   | 0    | #00FF00   
    4 : cyan           | standard | primary | 0   | 255   | 255  | #00FFFF   
    5 : blue           | standard | primary | 0   | 0     | 255  | #0000FF   
    6 : magenta        | standard | primary | 255 | 0     | 255  | #FF00FF   
    7 : dark red X     | darkened | primary | 51  | 0     | 0    | #330000   
    8 : dark yellow X  | darkened | primary | 51  | 51    | 0    | #333300   
    9 : dark green X   | darkened | primary | 0   | 51    | 0    | #003300   
   10 : dark cyan X    | darkened | primary | 0   | 51    | 51   | #003333   
   11 : dark blue X    | darkened | primary | 0   | 0     | 51   | #000033   
   12 : dark magenta X | darkened | primary | 51  | 0     | 51   | #330033   


    Saved table(s) to EXCEL file 'Images/Style_Darkened_Colors.xlsx' containing 1 sheets.

Try it yourself: Open LIB_Function_darken_colors.b4p in B4P_Examples.zip. Decompress before use.

Viewing the Results:

Test Click on the file name view the result: Style_Darkened_Colors.html.
Test Click on the file name open the file with Excel XML 2003: Style_Darkened_Colors.xls (Excel XML 2003 format - confirm the message box query).
Test Click on the file name open the file with Excel (.xlsx) : Style_Darkened_Colors.xlsx (Excel .xlsx format).

See also

darken color
lighten colors
weaken colors