PINE LIBRARY
Mis à jour

Color

1 519
Utility for working with colors.

Get the luminosity of a color and determine the optimal (black or white) foreground color.
Notes de version
v2

Added:
equals(color a, color b) function that deals with na values.
Notes de version
v3

Added:
tostringRGBT(color)
  Converts a color value to a string in the "rgbt(r,g,b,t)" format.
  Parameters:
    color: The color to convert.
  Returns: The color value as a string.

toHexChar(n)
  Converts an integer between 0 and 15 to its hex equivalent character.
  Parameters:
    n: The integer value to convert.

byteToHex(n)
  Converts an integer from 0 to 255 to a 2-character hex string.
  Parameters:
    n: The integer value to convert.

toHex(color)
  Converts a color to its hex string (#FFFFFF).
  Parameters:
    color
  Returns: The six digit hex string.
Notes de version
v4

Updated:
getContrastColor(bgColor, keepNa)
  Returns a color that is either black or white depending on the luminosity of the given background color. If the background color is na, returns gray.
  Parameters:
    bgColor: The background color to determine the contrast color for.
    keepNa: When true and the value of bgColor is na the return value will be na; otherwise the if bgColor is na the return will be gray.
  Returns: A color that provides high contrast with the given background color.
Notes de version
v5
Notes de version
v6

Added:
brighten(c, value)
  Proportionally adjusts the RGB values of a color. A value of positive (+) 100 will result in white. A value of negative (-) 100 will result in black.
  Parameters:
    c: The color to adjust.
    value: The amount (-100 to +100) to adjust the color by. Values less than -100 or greater than +100 will be clamped.
  Returns: The resultant color.

darken(c, value)
  Proportionally adjusts the RGB values of a color. A value of positive (+) 100 will result in black. A value of negative (-) 100 will result in white.
  Parameters:
    c: The color to adjust.
    value: The amount (-100 to +100) to adjust the color by. Values less than -100 or greater than +100 will be clamped.
  Returns: The resultant color.
Notes de version
v7 Fixes to brighten
Notes de version
v8 Fixes to brighten
Notes de version
v9 Added extension syntax.
Notes de version
v10 Upgraded to v6. Added "blending" functions/methods

Added:
lerp(color1, color2, t)
  Linear interpolation between two colors.
  Parameters:
    color1 (color): The first color.
    color2 (color): The second color.
    t (float): The interpolation factor (0.0 = color1, 1.0 = color2).
  Returns: The interpolated color.

method blendWith(this, toColor, t)
  Blends this color with another color using linear interpolation.
  Namespace types: series color, simple color, input color, const color
  Parameters:
    this (color): The starting color.
    toColor (color): The target color to blend with.
    t (float): The blend factor (0.0 = this, 1.0 = toColor).
  Returns: The blended color.

Clause de non-responsabilité

Les informations et les publications ne sont pas destinées à être, et ne constituent pas, des conseils ou des recommandations en matière de finance, d'investissement, de trading ou d'autres types de conseils fournis ou approuvés par TradingView. Pour en savoir plus, consultez les Conditions d'utilisation.