defmodule Pdf.Color do
  @moduledoc """
  A list of predefined colors you can use
  """
  @colors [
    {:pink, {0xFF, 0xC0, 0xCB}},
    {:light_pink, {0xFF, 0xB6, 0xC1}},
    {:hot_pink, {0xFF, 0x69, 0xB4}},
    {:deep_pink, {0xFF, 0x14, 0x93}},
    {:pale_violet_red, {0xDB, 0x70, 0x93}},
    {:medium_violet_red, {0xC7, 0x15, 0x85}},
    {:light_salmon, {0xFF, 0xA0, 0x7A}},
    {:salmon, {0xFA, 0x80, 0x72}},
    {:dark_salmon, {0xE9, 0x96, 0x7A}},
    {:light_coral, {0xF0, 0x80, 0x80}},
    {:indian_red, {0xCD, 0x5C, 0x5C}},
    {:crimson, {0xDC, 0x14, 0x3C}},
    {:firebrick, {0xB2, 0x22, 0x22}},
    {:dark_red, {0x8B, 0x00, 0x00}},
    {:red, {0xFF, 0x00, 0x00}},
    {:orange_red, {0xFF, 0x45, 0x00}},
    {:tomato, {0xFF, 0x63, 0x47}},
    {:coral, {0xFF, 0x7F, 0x50}},
    {:dark_orange, {0xFF, 0x8C, 0x00}},
    {:orange, {0xFF, 0xA5, 0x00}},
    {:yellow, {0xFF, 0xFF, 0x00}},
    {:light_yellow, {0xFF, 0xFF, 0xE0}},
    {:lemon_chiffon, {0xFF, 0xFA, 0xCD}},
    {:light_goldenrod_yellow, {0xFA, 0xFA, 0xD2}},
    {:papaya_whip, {0xFF, 0xEF, 0xD5}},
    {:moccasin, {0xFF, 0xE4, 0xB5}},
    {:peach_puff, {0xFF, 0xDA, 0xB9}},
    {:pale_goldenrod, {0xEE, 0xE8, 0xAA}},
    {:khaki, {0xF0, 0xE6, 0x8C}},
    {:dark_khaki, {0xBD, 0xB7, 0x6B}},
    {:gold, {0xFF, 0xD7, 0x00}},
    {:cornsilk, {0xFF, 0xF8, 0xDC}},
    {:blanched_almond, {0xFF, 0xEB, 0xCD}},
    {:bisque, {0xFF, 0xE4, 0xC4}},
    {:navajo_white, {0xFF, 0xDE, 0xAD}},
    {:wheat, {0xF5, 0xDE, 0xB3}},
    {:burlywood, {0xDE, 0xB8, 0x87}},
    {:tan, {0xD2, 0xB4, 0x8C}},
    {:rosy_brown, {0xBC, 0x8F, 0x8F}},
    {:sandy_brown, {0xF4, 0xA4, 0x60}},
    {:goldenrod, {0xDA, 0xA5, 0x20}},
    {:dark_goldenrod, {0xB8, 0x86, 0x0B}},
    {:peru, {0xCD, 0x85, 0x3F}},
    {:chocolate, {0xD2, 0x69, 0x1E}},
    {:saddle_brown, {0x8B, 0x45, 0x13}},
    {:sienna, {0xA0, 0x52, 0x2D}},
    {:brown, {0xA5, 0x2A, 0x2A}},
    {:maroon, {0x80, 0x00, 0x00}},
    {:dark_olive_green, {0x55, 0x6B, 0x2F}},
    {:olive, {0x80, 0x80, 0x00}},
    {:olive_drab, {0x6B, 0x8E, 0x23}},
    {:yellow_green, {0x9A, 0xCD, 0x32}},
    {:lime_green, {0x32, 0xCD, 0x32}},
    {:lime, {0x00, 0xFF, 0x00}},
    {:lawn_green, {0x7C, 0xFC, 0x00}},
    {:chartreuse, {0x7F, 0xFF, 0x00}},
    {:green_yellow, {0xAD, 0xFF, 0x2F}},
    {:spring_green, {0x00, 0xFF, 0x7F}},
    {:medium_spring_green, {0x00, 0xFA, 0x9A}},
    {:light_green, {0x90, 0xEE, 0x90}},
    {:pale_green, {0x98, 0xFB, 0x98}},
    {:dark_sea_green, {0x8F, 0xBC, 0x8F}},
    {:medium_aquamarine, {0x66, 0xCD, 0xAA}},
    {:medium_sea_green, {0x3C, 0xB3, 0x71}},
    {:sea_green, {0x2E, 0x8B, 0x57}},
    {:forest_green, {0x22, 0x8B, 0x22}},
    {:green, {0x00, 0x80, 0x00}},
    {:dark_green, {0x00, 0x64, 0x00}},
    {:aqua, {0x00, 0xFF, 0xFF}},
    {:cyan, {0x00, 0xFF, 0xFF}},
    {:light_cyan, {0xE0, 0xFF, 0xFF}},
    {:pale_turquoise, {0xAF, 0xEE, 0xEE}},
    {:aquamarine, {0x7F, 0xFF, 0xD4}},
    {:turquoise, {0x40, 0xE0, 0xD0}},
    {:medium_turquoise, {0x48, 0xD1, 0xCC}},
    {:dark_turquoise, {0x00, 0xCE, 0xD1}},
    {:light_sea_green, {0x20, 0xB2, 0xAA}},
    {:cadet_blue, {0x5F, 0x9E, 0xA0}},
    {:dark_cyan, {0x00, 0x8B, 0x8B}},
    {:teal, {0x00, 0x80, 0x80}},
    {:light_steel_blue, {0xB0, 0xC4, 0xDE}},
    {:powder_blue, {0xB0, 0xE0, 0xE6}},
    {:light_blue, {0xAD, 0xD8, 0xE6}},
    {:sky_blue, {0x87, 0xCE, 0xEB}},
    {:light_sky_blue, {0x87, 0xCE, 0xFA}},
    {:deep_sky_blue, {0x00, 0xBF, 0xFF}},
    {:dodger_blue, {0x1E, 0x90, 0xFF}},
    {:cornflower_blue, {0x64, 0x95, 0xED}},
    {:steel_blue, {0x46, 0x82, 0xB4}},
    {:royal_blue, {0x41, 0x69, 0xE1}},
    {:blue, {0x00, 0x00, 0xFF}},
    {:medium_blue, {0x00, 0x00, 0xCD}},
    {:dark_blue, {0x00, 0x00, 0x8B}},
    {:navy, {0x00, 0x00, 0x80}},
    {:midnight_blue, {0x19, 0x19, 0x70}},
    {:lavender, {0xE6, 0xE6, 0xFA}},
    {:thistle, {0xD8, 0xBF, 0xD8}},
    {:plum, {0xDD, 0xA0, 0xDD}},
    {:violet, {0xEE, 0x82, 0xEE}},
    {:orchid, {0xDA, 0x70, 0xD6}},
    {:fuchsia, {0xFF, 0x00, 0xFF}},
    {:magenta, {0xFF, 0x00, 0xFF}},
    {:medium_orchid, {0xBA, 0x55, 0xD3}},
    {:medium_purple, {0x93, 0x70, 0xDB}},
    {:blue_violet, {0x8A, 0x2B, 0xE2}},
    {:dark_violet, {0x94, 0x00, 0xD3}},
    {:dark_orchid, {0x99, 0x32, 0xCC}},
    {:dark_magenta, {0x8B, 0x00, 0x8B}},
    {:purple, {0x80, 0x00, 0x80}},
    {:indigo, {0x4B, 0x00, 0x82}},
    {:dark_slate_blue, {0x48, 0x3D, 0x8B}},
    {:slate_blue, {0x6A, 0x5A, 0xCD}},
    {:medium_slate_blue, {0x7B, 0x68, 0xEE}},
    {:white, {0xFF, 0xFF, 0xFF}},
    {:snow, {0xFF, 0xFA, 0xFA}},
    {:honeydew, {0xF0, 0xFF, 0xF0}},
    {:mint_cream, {0xF5, 0xFF, 0xFA}},
    {:azure, {0xF0, 0xFF, 0xFF}},
    {:alice_blue, {0xF0, 0xF8, 0xFF}},
    {:ghost_white, {0xF8, 0xF8, 0xFF}},
    {:white_smoke, {0xF5, 0xF5, 0xF5}},
    {:seashell, {0xFF, 0xF5, 0xEE}},
    {:beige, {0xF5, 0xF5, 0xDC}},
    {:old_lace, {0xFD, 0xF5, 0xE6}},
    {:floral_white, {0xFF, 0xFA, 0xF0}},
    {:ivory, {0xFF, 0xFF, 0xF0}},
    {:antique_white, {0xFA, 0xEB, 0xD7}},
    {:linen, {0xFA, 0xF0, 0xE6}},
    {:lavender_blush, {0xFF, 0xF0, 0xF5}},
    {:misty_rose, {0xFF, 0xE4, 0xE1}},
    {:gainsboro, {0xDC, 0xDC, 0xDC}},
    {:light_gray, {0xD3, 0xD3, 0xD3}},
    {:silver, {0xC0, 0xC0, 0xC0}},
    {:dark_gray, {0xA9, 0xA9, 0xA9}},
    {:gray, {0x80, 0x80, 0x80}},
    {:dim_gray, {0x69, 0x69, 0x69}},
    {:light_slate_gray, {0x77, 0x88, 0x99}},
    {:slate_gray, {0x70, 0x80, 0x90}},
    {:dark_slate_gray, {0x2F, 0x4F, 0x4F}},
    {:black, {0x00, 0x00, 0x00}}
  ]

  @doc """
  This functions returns the `rgb` tuple for the given color.

  #{Enum.map(@colors, fn {color_name, {r, g, b}} -> "<li style='color: rgb(#{r},#{g},#{b}); margin-right: 6px;'>:#{color_name}</li>" end) |> Enum.join("\n")}
  """

  @spec color(Pdf.color_name()) :: Pdf.rgb()
  Enum.each(@colors, fn {func_name, {r, g, b}} ->
    def color(unquote(func_name)), do: {unquote(r), unquote(g), unquote(b)}
  end)

  def color(color), do: raise(ArgumentError, "Undefined color #{color}")
end
