Library "colorLab" The ColorLab library presents an essential solution for color optimization, leveraging color terms and philosophy. Through its capabilities, it furnishes the necessary versatility to attain optimal color representation and coherence by integrating functions.
tint_level(colour, level) Determines a Tinted color Parameters: colour (color): (series color) Pure color. level (float): (series float) Optional argument, default = 50. A level of tent color. 0 is entered color and 100 is white color. Returns: (series color) A color Computed from a linear "Tint" gradient.
shade_level(colour, level) Determines a Shaded color. Parameters: colour (color): (series color) Pure color. level (float): (series float) Optional argument, default = 50. A level of tent color. 0 is entered color and 100 is Black color. Returns: (series color) A color Computed from a linear "Shade" gradient.
tone_level(colour, level) Determines a Tone color. Parameters: colour (color): (series color) Pure color. level (float): (series float) Optional argument, default = 50. A level of tent color. 0 is entered color and 100 is Gray color. Returns: (series color) A color Computed from a linear "Tone" gradient.
lightness_gradient(colour, value, bottom_value, top_value, bottom_lightness, top_lightness) Determines a color from a "Lightness" gradient, based on the position of an entered value within a defined range. Parameters: colour (color): (series color) Pure color. value (float): (series float) Value. bottom_value (float): (series float) Bottom Value. top_value (float): (series float) Top Value. bottom_lightness (simple float): (simple float) Optional argument, default = 70. Lightness Percentage. 100% is lightest and 0% is darkest top_lightness (simple float): (simple float) Optional argument, default = 30. Lightness Percentage. 100% is lightest and 0% is darkest Returns: (series color) A color Computed a the linear "Lightness" gradient.
saturation_gradient(colour, value, bottom_value, top_value, bottom_saturated, top_saturated) Determines a color from a "Saturation" gradient, based on the position of an entered value within a defined range. Parameters: colour (color): (series color) Pure color. value (float): (series float) Value. bottom_value (float): (series float) Bottom Value. top_value (float): (series float) Top Value. bottom_saturated (simple float): (simple float) Optional argument, default = 15. Low Saturated Percentage. top_saturated (simple float): (simple float) Optional argument, default = 80. High Saturated Percentage. Returns: (series color) A color Computed from a linear "Saturation" gradient.
hue_gradient(colour, value, bottom_value, top_value, bottom_hue, top_hue) Determines a color from a "Hue" gradient, based on the position of an entered value within a defined range. Parameters: colour (color): (series color) Pure color. value (float): (series float) Value. bottom_value (float): (series float) Bottom Value. top_value (float): (series float) Top Value. bottom_hue (simple float): (simple float) Optional argument, Default = 0. Low Hue is a degree where value in range 0 to 360 degrees. top_hue (simple float): (simple float) Optional argument, default = 300. High Hue is a degree where value in range 0 to 360 degrees. Returns: (series color) A color Computed from a linear "Saturation" gradient.
opposColor(colour) Generates the opposite color of inputted color. Parameters: colour (color): (series color) Pure color. Returns: (series color) An opposite color.
randColor(seed) Generates a random color. Parameters: seed (simple int): (simple int) Optional argument. With identifying seed, it will generate similar color sequence. Returns: (series color) A random color.
bk_or_wh(colour, lightness) Determines a white or back fits with an inputted color. Parameters: colour (color): (series color) Pure color. lightness (float): (series float) Optional argument, default = 50. If the lightness percentage of inputted color is higher, the output is white; otherwise, it's black. Returns: (series color) white or back color.
monochrome(colour, lightness, saturation) Generates a monochromatic color scheme. Parameters: colour (color): (series color) Pure color. lightness (float): (series float) Optional argument, default = NA. To custom Lightness percentage manually, 100% is lightest and 0% is darkest. saturation (float): (series float) Optional argument, default = NA. To custom Saturation percentage manually, 100% is highest and 0% is lowest saturated. Returns: (tuple of two color series) [entered color, monochromatic color].
complementary(colour) Generates a complementary color scheme. Parameters: colour (color): (series color) Pure color. Returns: (tuple of two color series) [entered color, complementary color].
analogous(colour) Generates an analogous color scheme. Parameters: colour (color): (series color) Pure color. Returns: (tuple of three color series) [entered color, color2, color3].
triadic(colour) Generates an Triadic color scheme. Parameters: colour (color): (series color) Pure color. Returns: (tuple of three color series) [entered color, color2, color3].
tetradic(colour) Generates an Tetradic color scheme. Parameters: colour (color): (series color) Main color. Returns: (tuple of four color series) [entered color, color2, color3, color4].
tst_scheme(colour, size, _type) Generates an array of requested type (tint, shade, or tone) scheme colors. Parameters: colour (simple color): (simple color) Pure color. size (simple int): (simple input) Number of elements in color array. _type (simple string): (simple string) Type of color scheme, possible input "tint", "shade", and "tone". Returns: (simple array<color>) An array contains elements of the requested type scheme colors.
lsh_scheme(colour, size, _type, topLevel, botLevel) Generates an array of requested type (lightness, saturation or hue) scheme colors. Parameters: colour (simple color): (simple color) Pure color. size (simple int): (simple input) Number of elements in color array. _type (simple string): (simple string) Type of color scheme, possible input "lightness", "saturation" and "hue". topLevel (simple float): (simple float) Optional argument, default = NA. 1. if "lightness", in a percentage where value in range 0 to 100, 100% lightest. 2. if "saturation", in a percentage where value in range 0 to 100, 100% highest saturated. 3. if "hue", in a degree where value in range 0 to 360 degrees. botLevel (simple float): (simple float) Optional argument, default = NA. 1. if "lightness", in a percentage where value in range 0 to 100, 0% darkest. 2. if "saturation", in a percentage where value in range 0 to 100, 0% lowest saturated. 3. if "hue", in a degree where value in range 0 to 360 degrees. Returns: (simple array<color>) An array contains elements of the requested type scheme colors.
display_color(colour, location) Displays color including RGB and HSL. Parameters: colour (simple color): (simple color) Pure color. location (simple string): (simple string) Optional argument, default = "top_right". cell location. Returns: (simple table) A table cell contains RGB and HSL of entered color.
display_scheme(arrayColour, location) Displays Scheme colors including RGB and HSL. Parameters: arrayColour (array<color>) location (simple string): (simple string) Optional argument, default = "top_right". cell location. Returns: (simple table) A table cells contain RGB and HSL of entered color.
In true TradingView spirit, the author has published this Pine code as an open-source library so that other Pine programmers from our community can reuse it. Cheers to the author! You may use this library privately or in other open-source publications, but reuse of this code in a publication is governed by House rules.
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.