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.
sass_cleanup (buf) Cleanup sass variables
sass_update_variables (buf, line_start, line_end, lines, color_parser, options, options_local) Parse the given lines for sass variabled and add to SASS[buf].DEFINITIONS_ALL.
sass_name_parser (line, i, buf) Parse the given line for sass color names check for value in SASS[buf].DEFINITIONS_ALL
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
sass_cleanup (buf)
Cleanup sass variables

Parameters:

  • buf number
sass_update_variables (buf, line_start, line_end, lines, color_parser, options, options_local)
Parse the given lines for sass variabled and add to SASS[buf].DEFINITIONSALL. which is then used in |sassnameparser| If lines are not given, then fetch the lines with linestart and line_end

Parameters:

  • buf number
  • line_start number
  • line_end number
  • lines table|nil
  • color_parser function|boolean
  • options table: Buffer options
  • options_local table|nil: Buffer local variables

Returns:

    boolean
sass_name_parser (line, i, buf)
Parse the given line for sass color names check for value in SASS[buf].DEFINITIONS_ALL

Parameters:

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

Returns:

    number|nil, string|nil
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