Module colorizer.color_utils

Helper functions to parse different colour formats

Functions

color_is_bright (r, g, b) Determine whether to use black or white text.
color_name_parser (line, i, opts) Grab all the colour values from vim.api.nvim_get_color_map and create a lookup table.
rgb_function_parser (line, i) Parse for rgb() css function and return rgb hex.
rgba_function_parser (line, i) Parse for rgba() css function and return rgb hex.
hsl_function_parser (line, i) Parse for hsl() css function and return rgb hex.
hsla_function_parser (line, i) Parse for hsl() css function and return rgb hex.
argb_hex_parser (line, i) parse for 0xaarrggbb and return rgb hex.
rgba_hex_parser (line, i, opts) parse for #rrggbbaa and return rgb hex.


Functions

color_is_bright (r, g, b)
Determine whether to use black or white text.

ref: https://stackoverflow.com/a/1855903/837964 https://stackoverflow.com/questions/596216/formula-to-determine-brightness-of-rgb-color

Parameters:

  • r number: Red
  • g number: Green
  • b number: Blue
color_name_parser (line, i, opts)
Grab all the colour values from vim.api.nvim_get_color_map and create a lookup table. COLOR_MAP is used to store the colour values

Parameters:

  • line string: Line to parse
  • i number: Index of line from where to start parsing
  • opts table: Currently contains whether tailwind is enabled or not
rgb_function_parser (line, i)
Parse for rgb() css function and return rgb hex.

Parameters:

  • line string: Line to parse
  • i number: Index of line from where to start parsing

Returns:

  1. number|nil: Index of line where the rgb function ended
  2. string|nil: rgb hex value
rgba_function_parser (line, i)
Parse for rgba() css function and return rgb hex. Todo consider removing the regexes here Todo this might not be the best approach to alpha channel. Things like pumblend might be useful here.

Parameters:

  • line string: Line to parse
  • i number: Index of line from where to start parsing

Returns:

  1. number|nil: Index of line where the rgba function ended
  2. string|nil: rgb hex value
hsl_function_parser (line, i)
Parse for hsl() css function and return rgb hex.

Parameters:

  • line string: Line to parse
  • i number: Index of line from where to start parsing

Returns:

  1. number|nil: Index of line where the hsl function ended
  2. string|nil: rgb hex value
hsla_function_parser (line, i)
Parse for hsl() css function and return rgb hex.

Parameters:

  • line string: Line to parse
  • i number: Index of line from where to start parsing

Returns:

  1. number|nil: Index of line where the hsla function ended
  2. string|nil: rgb hex value
argb_hex_parser (line, i)
parse for 0xaarrggbb and return rgb hex. a format used in android apps

Parameters:

  • line string: line to parse
  • i number: index of line from where to start parsing

Returns:

  1. number|nil: index of line where the hex value ended
  2. string|nil: rgb hex value
rgba_hex_parser (line, i, opts)
parse for #rrggbbaa and return rgb hex. a format used in android apps

Parameters:

  • line string: line to parse
  • i number: index of line from where to start parsing
  • opts table: Containing minlen, maxlen, valid_lengths

Returns:

  1. number|nil: index of line where the hex value ended
  2. string|nil: rgb hex value
generated by LDoc 1.4.6 Last updated - September