View Source ColorPalette.DataConverter (ColorPalette v0.1.10)

The functions in ColorPalette.DataConverter are all pure functions for testability (as opposed to those in ColorPalette which reference statically compiled data).

Summary

Functions

Link to this function

ansi_color_codes_to_color_names(ansi_color_codes, hex_to_color_names)

View Source
@spec ansi_color_codes_to_color_names([ColorPalette.ANSIColorCode.t()], %{
  required(ColorPalette.ANSIColorCode.hex()) => [ColorPalette.Color.name()]
}) :: %{required(ColorPalette.ANSIColorCode.t()) => [ColorPalette.Color.name()]}
Link to this function

codes_by_frequency_count(colors)

View Source
@spec codes_by_frequency_count(%{
  required(ColorPalette.Color.name()) => [ColorPalette.Color.t()]
}) :: %{
  ColorPalette.ANSIColorCode => integer()
}
Link to this function

codes_to_name_counts(colors)

View Source
@spec codes_to_name_counts(%{
  required(ColorPalette.Color.name()) => [ColorPalette.Color.t()]
}) :: %{
  ColorPalette.ANSIColorCode => integer()
}
@spec codes_to_names(%{
  required(ColorPalette.Color.name()) => [ColorPalette.Color.t()]
}) :: %{
  ColorPalette.ANSIColorCode => [ColorPalette.Color.name()]
}
Link to this function

collate_colors_by_name(colors)

View Source
@spec collate_colors_by_name([ColorPalette.Color.t()]) :: %{
  required(ColorPalette.Color.name()) => [ColorPalette.Color.t()]
}
Link to this function

color_groups_to_ansi_color_codes(ansi_color_codes, color_groups)

View Source
@spec color_groups_to_ansi_color_codes([ColorPalette.ANSIColorCode.t()], [
  ColorPalette.ColorGroup.t()
]) ::
  %{required(ColorPalette.ColorGroup.t()) => [ColorPalette.ANSIColorCode.t()]}
Link to this function

color_name_to_atom(name)

View Source
@spec color_name_to_atom(String.t()) :: [ColorPalette.Color.name()]
Link to this function

color_names_to_colors(colors)

View Source
@spec color_names_to_colors([ColorPalette.Color.t()]) :: %{
  required(ColorPalette.Color.name()) => [ColorPalette.Color.t()]
}
Link to this function

combine_colors_with_same_name(colors)

View Source
@spec combine_colors_with_same_name(%{
  required(ColorPalette.Color.name()) => [ColorPalette.Color.t()]
}) ::
  %{required(ColorPalette.Color.name()) => [ColorPalette.Color.t()]}
Link to this function

combine_colors_with_same_name_and_code(colors)

View Source
@spec combine_colors_with_same_name_and_code([ColorPalette.Color.t()]) ::
  ColorPalette.Color.t()
Link to this function

compute_stats(colors_collated)

View Source
@spec compute_stats(%{required(ColorPalette.Color.name()) => [ColorPalette.Color.t()]}) ::
  %{
    required(ColorPalette.ANSIColorCode.code()) => %{
      sources: [ColorPalette.Color.source()],
      other_names: [ColorPalette.Color.name()]
    }
  }
Link to this function

convert_raw_color_data_to_colors(raw_color_data, source, ansi_color_codes)

View Source
@spec convert_raw_color_data_to_colors([map()], ColorPalette.Color.source(), [
  ColorPalette.ANSIColorCode.t()
]) :: [[ColorPalette.Color.t()]]
Link to this function

create_names_for_missing_colors(all_colors, color_codes_missing_names)

View Source
@spec create_names_for_missing_colors(
  %{required(ColorPalette.Color.name()) => ColorPalette.Color.t()},
  [ColorPalette.ANSIColorCode.code()]
) :: %{required(ColorPalette.Color.name()) => ColorPalette.Color.t()}
Link to this function

fill_in_same_as_field(colors, hex_to_color_names)

View Source
@spec fill_in_same_as_field(
  %{required(ColorPalette.Color.name()) => ColorPalette.Color.t()},
  %{
    required(ColorPalette.ANSIColorCode.hex()) => [ColorPalette.Color.name()]
  }
) :: %{required(ColorPalette.Color.name()) => ColorPalette.Color.t()}
Link to this function

find_by_code(colors, code)

View Source
Link to this function

find_by_hex(color_names, hex)

View Source
Link to this function

group_by_name_frequency(colors)

View Source
@spec group_by_name_frequency(%{
  required(ColorPalette.Color.name()) => [ColorPalette.Color.t()]
}) :: %{
  required(ColorPalette.Color.name()) => ColorPalette.Color.t()
}
Link to this function

hex_to_color_names(colors)

View Source
@spec hex_to_color_names(%{
  required(ColorPalette.Color.name()) => ColorPalette.Color.t()
}) :: %{
  required(ColorPalette.ANSIColorCode.hex()) => [ColorPalette.Color.name()]
}
Link to this function

normalize_data(color_data_api_value, code)

View Source
@spec normalize_data(map(), ColorPalette.ANSIColorCode.code()) :: map()
Link to this function

normalize_name_that_color_data(name_that_color_raw_data, data_with_text_contrast_color)

View Source
@spec normalize_name_that_color_data([map()], [map()]) :: [map()]
Link to this function

unnamed_ansi_color_codes(color_map)

View Source
@spec unnamed_ansi_color_codes(%{
  required(ColorPalette.Color.name()) => ColorPalette.Color.t()
}) :: [
  ColorPalette.ANSIColorCode.code()
]