PINE LIBRARY
Cập nhật colorLab

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.
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.
Phát hành các Ghi chú
▋▋ Version 2 of "colorLab" Library ▋▋▋ SECTION#1: HTML Color
Example:
//@version=6
indicator("ColorLab_Example")
import MUQWISHI/colorLab/2 as cl
plot(close, "Lawn Green Color", color=cl.LawnGreen)
▋ SECTION#2: Function Reference
toRGB(color)
Converts a Color to an RGB Array.
Returns: ([float, float, float]) A tuple containing Red, Green, and Blue values (0-255).
---
toHSL(color)
Converts a Color to HSL (Hue, Saturation, Lightness) values.
Returns: ([float, float, float]) A tuple containing Hue (0-360), Saturation (0-100)%, and Lightness (0-100)%.
---
rgb(R, G, B)
Creates a new color using the RGB color model.
Returns: (color) The resulting color.
---
hsl(H, S, L)
Creates a new color using the HSL color model.
Returns: (color) The resulting color.
---
inverse(color)
Generates the exact opposite color on the RGB scale.
Returns: (color) The inverse color.
---
textColor(color)
Determines if White or Black text provides better contrast for a given background.
Parameters:
Returns: (color) A text color with either Black or White.
---
iff(condition, positive, negative)
Returns a color based on a condition.
Returns: (color) The state color.
---
random(seed)
Generates a random color.
Returns: (color) A randomly generated RGB color.
---
mixTwo(color1, color2)
Mixes two colors into a single composite color with equal weighting.
Returns: (color) The resulting "Average" color of the collection.
---
mix(colors)
Mixes an array of colors into a single composite color.
Returns: (color) The resulting "Average" color of the collection.
---
grayScale(color)
Converts a color to its perceptual grayscale value (Luminance).
Returns: (color) A grayscale color that matches the perceived brightness of the original.
---
temperature(color, value, minVal, maxVal)
Adjusts the color temperature (Warmth/Coolness) based on a value's position within a range.
Returns: (color) The temperature-shifted color.
---
heatmap(value, minVal, midVal, maxVal, startColor, midColor, endColor)
Generates a 3-stop diverging gradient (e.g., Green -> Yellow -> Red).
Returns: (color) The resulting gradient color.
---
zScore(value, length, positiveColor, negativeColor, neutralColor, threshold)
Generates a color based on Standard Deviations (Z-Score) from the mean.
Returns: (color) A gradient color representing statistical extremity.
---
tint(color, intensity)
Generates a "Tint" (mix with White).
Returns: (color) The tinted color.
---
shade(color, intensity)
Generates a "Shade" (mix with Black).
Returns: (color) The shaded color.
---
tone(color, intensity)
Generates a "Tone" (mix with Gray).
Returns: (color) The toned color.
---
gradientLightness(color, value, minRange, maxRange, darkLimit, lightLimit)
Calculates a color based on a Lightness gradient mapped to a data series.
Returns: (color) The resulting color with adjusted lightness.
---
gradientSaturation(color, value, minRange, maxRange, lowSat, highSat)
Calculates a color based on a Saturation gradient mapped to a data series.
Returns: (color) The resulting color with adjusted saturation.
---
gradientHue(color, value, minRange, maxRange, startHue, endHue)
Calculates a color based on a Hue gradient (shift) mapped to a data series.
Returns: (color) The resulting color with shifted Hue.
---
harmonyMonochrome(color, customLightness, customSaturation)
Generates a Monochromatic color scheme (variations in Lightness/Saturation).
Returns: ([color, color]) A tuple containing [Base Color, Monochromatic Variant].
---
harmonyComplementary(color)
Generates a Complementary color scheme (180 degrees opposite on the wheel).
Returns: ([color, color]) A tuple containing [Base Color, Complementary Color].
---
harmonySplitComplementary(color)
Generates a Split Complementary scheme (Two colors adjacent to the complement on
Returns: ([color, color, color]) A tuple containing [Base Color, Split#1 Color, Split#2 Color].
---
harmonyAnalogous(color)
Generates an Analogous color scheme (Two colors [+/- 45 degrees] adjacent on the color wheel).
Returns: ([color, color, color]) A tuple containing [Base Color, -45deg Neighbor Color, +45deg Neighbor Color].
---
harmonyTriadic(color)
Generates a Triadic color scheme (Three colors evenly spaced by 120 degrees adjacent on the color wheel).
Returns: ([color, color, color]) A tuple containing [Base Color, +120deg Color, +240deg Color].
---
harmonyTetradic(color)
Generates a Tetradic color scheme (four colors spaced 60 degrees around the color wheel).
Returns: ([color, color, color, color]) A tuple containing [Base Color, +90deg Color, +180deg Color, +270deg Color].
---
schemeTST(color, count, mode)
Generates an array of Tint, Shade, or Tone colors.
Returns: (array<color>) An array of generated colors.
---
schemeLSH(color, count, mode, upperLimit, lowerLimit)
Generates an array of Lightness, Saturation, or Hue gradients.
Parameters:
mode (simple string): (simple string) The attribute to vary: "lightness", "saturation", or "hue".
Returns: (array<color>) An array of generated colors.
---
visualizeColor(color, position)
Displays a single color's details (RGB/HSL values) in a table on the chart.
Returns: Draws a colors table on the chart.
---
visualizeScheme(colorArray, position)
Displays an entire color scheme array in a grid table on the chart, each color has its (RGB/HSL values).
Returns: Draws a colors table on the chart.
Thư viện Pine
Theo đúng tinh thần TradingView, tác giả đã công bố mã Pine này như một thư viện mã nguồn mở để các lập trình viên Pine khác trong cộng đồng có thể tái sử dụng. Chúc mừng tác giả! Bạn có thể sử dụng thư viện này cho mục đích cá nhân hoặc trong các ấn phẩm mã nguồn mở khác, nhưng việc tái sử dụng mã này trong các ấn phẩm phải tuân theo Nội Quy.
Trusted Pine Programmer, For Coding Inquiries
► Website muqwishi.com/home/quotation/
► Telegram t.me/MUQWISHI
► Email service@muqwishi.com
⛾ Support My Work on “Buy Me a Coffee” buymeacoffee.com/muqwishi
► Website muqwishi.com/home/quotation/
► Telegram t.me/MUQWISHI
► Email service@muqwishi.com
⛾ Support My Work on “Buy Me a Coffee” buymeacoffee.com/muqwishi
Thông báo miễn trừ trách nhiệm
Thông tin và các ấn phẩm này không nhằm mục đích, và không cấu thành, lời khuyên hoặc khuyến nghị về tài chính, đầu tư, giao dịch hay các loại khác do TradingView cung cấp hoặc xác nhận. Đọc thêm tại Điều khoản Sử dụng.
Thư viện Pine
Theo đúng tinh thần TradingView, tác giả đã công bố mã Pine này như một thư viện mã nguồn mở để các lập trình viên Pine khác trong cộng đồng có thể tái sử dụng. Chúc mừng tác giả! Bạn có thể sử dụng thư viện này cho mục đích cá nhân hoặc trong các ấn phẩm mã nguồn mở khác, nhưng việc tái sử dụng mã này trong các ấn phẩm phải tuân theo Nội Quy.
Trusted Pine Programmer, For Coding Inquiries
► Website muqwishi.com/home/quotation/
► Telegram t.me/MUQWISHI
► Email service@muqwishi.com
⛾ Support My Work on “Buy Me a Coffee” buymeacoffee.com/muqwishi
► Website muqwishi.com/home/quotation/
► Telegram t.me/MUQWISHI
► Email service@muqwishi.com
⛾ Support My Work on “Buy Me a Coffee” buymeacoffee.com/muqwishi
Thông báo miễn trừ trách nhiệm
Thông tin và các ấn phẩm này không nhằm mục đích, và không cấu thành, lời khuyên hoặc khuyến nghị về tài chính, đầu tư, giao dịch hay các loại khác do TradingView cung cấp hoặc xác nhận. Đọc thêm tại Điều khoản Sử dụng.