Skip to content
Reference > Methods

brighten(color,pctChange)

Definition

String brighten(String color, Number pctChange)

Description

Returns a new hexcode color that is a percentage brighter or darker than the supplied color. Input and output colors should be in #RRGGBB format. Returns null if argument is null.

Parameter Definition

Name Type Description
color String Color to brighten/darken, in rrggbb format
pctChange Number Pct to brighten or darken by, such that 0 is unchanged, 1 is 100% brighter and -1 is 100% darker

Examples

1
2
3
4
5
6
String r1 = brighten("#FF0000",0); // r1 == #ff0000
String r2 = brighten("#FF0000",0.5D); // r2 == #ff7f7f
String r3 = brighten("#FF0000",-0.5D); // r3 == #7f0000
String r4 = brighten("#880088",0); // r4 == #880088
String r5 = brighten("#880088",0.1D); // r5 == #931993
String r6 = brighten("#880880",-1); // r6 == #000000