%%
%% This is file `l3color.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% l3color.dtx  (with options: `package')
%% 
%% Copyright (C) 2017-2020 The LaTeX3 Project
%% 
%% It may be distributed and/or modified under the conditions of
%% the LaTeX Project Public License (LPPL), either version 1.3c of
%% this license or (at your option) any later version.  The latest
%% version of this license is in the file:
%% 
%%    http://www.latex-project.org/lppl.txt
%% 
%% This file is part of the "l3experimental bundle" (The Work in LPPL)
%% and all files in that bundle must be distributed together.
%% 
%% File: l3color.dtx
\RequirePackage{expl3}
\ProvidesExplPackage{l3color}{2020-07-17}{}
  {L3 Experimental color support}
\tl_new:N \l__color_internal_tl
\scan_new:N \s__color_mark
\prg_new_conditional:Npnn \__color_if_defined:n #1 { T, F, TF }
  {
    \prop_if_exist:cTF { l__color_named_ #1 _prop }
      \prg_return_true:
      \prg_return_false:
  }
\cs_new:Npn \__color_model:N #1 { \exp_after:wN \use_i:nn #1 }
\cs_new:Npn \__color_values:N #1 { \exp_after:wN \use_ii:nn #1 }
\cs_new_protected:Npn \__color_extract:nNN #1#2#3
  {
    \tl_set_eq:Nc #2 { l__color_named_ #1 _tl }
    \prop_get:cVN { l__color_named_ #1 _prop } #2 #3
  }
\cs_generate_variant:Nn \__color_extract:nNN { V }
\cs_new_protected:Npn \__color_convert:nnN #1#2#3
  { \__color_convert:nnVN {#1} {#2} #3 #3 }
\cs_generate_variant:Nn \__color_convert:nnN { VV }
\cs_new_protected:Npn \__color_convert:nnnN #1#2#3#4
  {
    \str_if_eq:nnT {#1} { spot } % TO DO!!!
      { }
    \tl_set:Nx #4
      { \use:c { __color_convert_ #1 _ #2 :w } #3 ~ 0 ~ 0 ~ 0 \s__color_stop }
  }
\cs_generate_variant:Nn \__color_convert:nnnN { nV , nnV }
\cs_new:Npn \__color_convert_gray_rgb:w #1 ~ #2 \s__color_stop
  { #1 ~ #1 ~ #1 }
\cs_new:Npn \__color_convert_gray_cmyk:w #1 ~ #2 \s__color_stop
  { 0 ~ 0 ~ 0 ~ \fp_eval:n { 1 - #1 } }
\cs_new:Npn \__color_convert_rgb_gray:w #1 ~ #2 ~ #3 ~ #4 \s__color_stop
  { \fp_eval:n { 0.3 * #1 + 0.59 * #2 + 0.11 * #3 } }
\cs_new:Npn \__color_convert_rgb_cmyk:w #1 ~ #2 ~ #3 ~ #4 \s__color_stop
  {
    \exp_args:Nf \__color_convert_rgb_cmyk:nnnn
      { \fp_eval:n { min ( 1 - #1 , 1 - #2 , 1 - #3 ) } } {#1} {#2} {#3}
  }
\cs_new:Npn \__color_convert_rgb_cmyk:nnnn #1#2#3#4
  {
    \fp_eval:n { min ( 1 , max ( 0 , 1 - #2 - #1 ) ) } \c_space_tl
    \fp_eval:n { min ( 1 , max ( 0 , 1 - #3 - #1 ) ) } \c_space_tl
    \fp_eval:n { min ( 1 , max ( 0 , 1 - #4 - #1 ) ) } \c_space_tl
    #1
  }
\cs_new:Npn \__color_convert_cmyk_gray:w #1 ~ #2 ~ #3 ~ #4 ~ #5 \s__color_stop
  { \fp_eval:n { 1 - min ( 1 , 0.3 * #1 + 0.59 * #2 + 0.11 * #3 + #4 ) } }
\cs_new:Npn \__color_convert_cmyk_rgb:w #1 ~ #2 ~ #3 ~ #4 ~ #5 \s__color_stop
  {
    \fp_eval:n { 1 - min ( 1 , #1 + #4 ) } \c_space_tl
    \fp_eval:n { 1 - min ( 1 , #2 + #4 ) } \c_space_tl
    \fp_eval:n { 1 - min ( 1 , #3 + #4 ) }
  }
\tl_new:N \l__color_model_tl
\tl_new:N \l__color_value_tl
\tl_new:N \l__color_next_model_tl
\tl_new:N \l__color_next_value_tl
\cs_new_protected:Npx \__color_parse:nN #1#2
  {
    \exp_not:N \__color_backend_pickup:N \exp_not:N \l__color_current_tl
    \tl_set:Nx \exp_not:c { l__color_named_ . _tl }
      { \exp_not:N \__color_model:N \exp_not:N \l__color_current_tl }
    \prop_put:NVx \exp_not:c { l__color_named_ . _prop }
      \exp_not:c { l__color_named_ . _tl }
      { \exp_not:N \__color_values:N \exp_not:N \l__color_current_tl }
    \exp_not:N \exp_args:Ne \exp_not:N \__color_parse_aux:nN
      { \exp_not:N \tl_to_str:n {#1} } #2
  }
\cs_new_protected:Npn \__color_parse_aux:nN #1#2
  {
    \tl_if_exist:cTF { l__color_named_ #1 _prop }
      { \__color_parse_set_eq:Nn #2 {#1} }
      { \__color_parse:Nw #2#1 ! \s__color_stop }
    \__color_check_model:N #2
  }
\cs_new_protected:Npn \__color_parse_set_eq:Nn #1#2
  {
    \tl_if_empty:NTF \l_color_fixed_model_tl
       { \exp_args:Nv \__color_parse_set_eq:nNn { l__color_named_ #2 _tl } }
       { \exp_args:NV \__color_parse_set_eq:nNn \l_color_fixed_model_tl }
         #1 {#2}
  }
\cs_new_protected:Npn \__color_parse_set_eq:nNn #1#2#3
  {
    \prop_get:cnNTF
      { l__color_named_ #3 _prop } {#1}
      \l__color_value_tl
      { \tl_set:Nx #2 { {#1} { \l__color_value_tl } } }
      {
        \tl_set_eq:Nc \l__color_model_tl { l__color_named_ #3 _tl }
        \prop_get:cVN { l__color_named_ #3 _prop } \l__color_model_tl
          \l__color_value_tl
         \__color_convert:nnN
           \l__color_model_tl {#1} \l__color_value_tl
        \tl_set:Nx #2
          {
            {#1}
            { \l__color_value_tl }
          }
      }
  }
\cs_new_protected:Npn \__color_parse:Nw #1#2 ! #3 \s__color_stop
  {
    \__color_if_defined:nTF {#2}
      {
        \tl_if_blank:nTF {#3}
          { \__color_parse_set_eq:Nn #1 {#2} }
          { \__color_parse_loop_init:Nnn #1 {#2} {#3} }
      }
      {
        \__kernel_msg_error:nnn { color } { unknown-color } {#2}
        \tl_set:Nn \l__color_current_tl { { gray } { 0 } }
      }
  }
\cs_new_protected:Npn \__color_parse_loop_init:Nnn #1#2#3
  {
    \group_begin:
      \__color_extract:nNN {#2} \l__color_model_tl \l__color_value_tl
      \__color_parse_loop:w #3 ! ! ! ! \s__color_stop
      \tl_set:Nx \l__color_internal_tl
        { { \l__color_model_tl } { \l__color_value_tl } }
    \exp_args:NNNV \group_end:
    \tl_set:Nn #1 \l__color_internal_tl
  }
\cs_new_protected:Npn \__color_parse_loop:w #1 ! #2 ! #3 ! #4 ! #5 \s__color_stop
  {
    \bool_lazy_or:nnF
      { \tl_if_blank_p:n {#1} }
      { \int_compare_p:nNn {#1} = { 100 } }
      {
        \int_compare:nNnTF {#1} = { 0 }
          {
            \tl_if_blank:nTF {#2}
              { \__color_extract:nNN { white } }
              { \__color_extract:nNN {#2} }
                \l__color_model_tl \l__color_value_tl
          }
          {
            \use:x
              {
                \__color_parse_loop:nn {#1}
                  { \tl_if_blank:nTF {#2} { white } {#2} }
              }
          }
      }
    \tl_if_blank:nF {#3}
      { \__color_parse_loop:w #3 ! #4 ! #5 \s__color_stop }
    \__color_parse_end:
  }
\cs_new_protected:Npn \__color_parse_loop:nn #1#2
  {
    \__color_if_defined:nTF {#2}
      {
        \__color_extract:nNN {#2} \l__color_next_model_tl \l__color_next_value_tl
        \tl_if_eq:NNF \l__color_model_tl \l__color_next_model_tl
          {
            \str_if_eq:VnTF \l__color_model_tl { gray }
              { \__color_parse_gray:n {#2} }
              { \__color_parse_std:n {#2} }
          }
        \tl_set:Nx \l__color_value_tl
          {
            \__color_parse_mix:NVVn
              \l__color_model_tl \l__color_value_tl \l__color_next_value_tl {#1}
          }
      }
      {
        \__kernel_msg_error:nnn { color } { unknown-color } {#2}
        \__color_extract:nNN { black } \l__color_model_tl \l__color_value_tl
        \__color_parse_break:w
      }
  }
\cs_new_protected:Npn \__color_parse_gray:n #1
  {
    \tl_set_eq:NN \l__color_model_tl \l__color_next_model_tl
    \tl_set:Nn \l__color_next_model_tl { gray }
    \exp_args:NnV \__color_convert:nnN { gray } \l__color_model_tl
      \l__color_value_tl
    \prop_get:cVN { l__color_named_ #1 _prop } \l__color_model_tl
      \l__color_next_value_tl
  }
\cs_new_protected:Npn \__color_parse_std:n #1
  {
    \prop_get:cVNF { l__color_named_ #1 _prop }
      \l__color_model_tl
      \l__color_next_value_tl
        {
          \__color_convert:VVN
            \l__color_next_model_tl
            \l__color_model_tl
            \l__color_next_value_tl
        }
  }
\cs_new_protected:Npn \__color_parse_break:w #1 \__color_parse_end: { }
\cs_new_protected:Npn \__color_parse_end: { }
\cs_new:Npn \__color_parse_mix:Nnnn #1#2#3#4
  {
    \exp_args:Nf \__color_parse_mix:nNnn
      { \fp_eval:n { #4 / 100 } }
      #1 {#2} {#3}
  }
\cs_generate_variant:Nn \__color_parse_mix:Nnnn { NVV }
\cs_new:Npn \__color_parse_mix:nNnn #1#2#3#4
  {
    \use:c { __color_parse_mix_ #2 :nw } {#1}
      #3 \s__color_mark #4 \s__color_stop
  }
\cs_new:Npn \__color_parse_mix_gray:nw #1#2 \s__color_mark #3 \s__color_stop
  { \fp_eval:n { #2 * #1 + #3 * ( 1 - #1 ) } }
\cs_new:Npn \__color_parse_mix_rgb:nw
  #1#2 ~ #3 ~ #4 \s__color_mark #5 ~ #6 ~ #7 \s__color_stop
  {
    \fp_eval:n { #2 * #1 + #5 * ( 1 - #1 ) } \c_space_tl
    \fp_eval:n { #3 * #1 + #6 * ( 1 - #1 ) } \c_space_tl
    \fp_eval:n { #4 * #1 + #7 * ( 1 - #1 ) }
  }
\cs_new:Npn \__color_parse_mix_cmyk:nw
  #1#2 ~ #3 ~ #4 ~ #5 \s__color_mark #6 ~ #7 ~ #8 ~ #9 \s__color_stop
  {
    \fp_eval:n { #2 * #1 + #6 * ( 1 - #1 ) } \c_space_tl
    \fp_eval:n { #3 * #1 + #7 * ( 1 - #1 ) } \c_space_tl
    \fp_eval:n { #4 * #1 + #8 * ( 1 - #1 ) } \c_space_tl
    \fp_eval:n { #5 * #1 + #9 * ( 1 - #1 ) }
  }
\cs_new:Npn \__color_parse_model_gray:w #1 , #2 \s__color_stop
  { { gray } { \__color_parse_number:n {#1} } }
\cs_new:Npn \__color_parse_model_rgb:w #1 , #2 , #3 , #4 \s__color_stop
  {
    { rgb }
    {
      \__color_parse_number:n {#1} ~
      \__color_parse_number:n {#2} ~
      \__color_parse_number:n {#3}
    }
  }
\cs_new:Npn \__color_parse_model_cmyk:w #1 , #2 , #3 , #4 , #5 \s__color_stop
  {
    { cmyk }
    {
      \__color_parse_number:n {#1} ~
      \__color_parse_number:n {#2} ~
      \__color_parse_number:n {#3} ~
      \__color_parse_number:n {#4}
    }
  }
\cs_new:Npn \__color_parse_model_spot:w #1 , #2 \s__color_stop
  {
    { spot }
    { \__color_parse_spot_aux:w #1 ! 100 ! \s__color_stop }
  }
\cs_new:Npn \__color_parse_spot_aux:w #1 ! #2 ! #3 \s__color_stop
  { #1 ~ \fp_eval:n { #2 / 100 } }
\cs_new:Npn \__color_parse_number:n #1
  {  \__color_parse_number:w #1 . 0 . \s__color_stop }
\cs_new:Npn \__color_parse_number:w #1 . #2 . #3 \s__color_stop
  { \tl_if_blank:nTF {#1} { 0 } {#1} . #2 }
\cs_new:Npn \__color_parse_model_Hsb:w #1 , #2 , #3 , #4 \s__color_stop
  {
    \exp_args:Ne \__color_parse_model_hsb:nnn { \fp_eval:n { #1 / 360 } }
      {#2} {#3}
  }
\cs_new:Npn \__color_parse_model_hsb:nnn #1#2#3
  {
    { rgb }
    {
      \exp_args:Ne \__color_parse_model_hsb_aux:nnn
        { \fp_eval:n { 6 * #1 } } {#2} {#3}
    }
  }
\cs_new:Npn \__color_parse_model_hsb_aux:nnn #1#2#3
  {
    \exp_args:Nee \__color_parse_model_hsb_aux:nnnn
      { \fp_eval:n { floor(#1) } } { \fp_eval:n { #1 - floor(#1) } }
      {#2} {#3}
  }
\cs_new:Npn \__color_parse_model_hsb_aux:nnnn #1#2#3#4
  {
    \use:e
      {
        \exp_not:N \__color_parse_model_hsb_aux:nnnnn
         { \__color_parse_number:n {#4} }
         { \fp_eval:n { round(#4 * (1 - #3) ,5) } }
         { \fp_eval:n { round(#4 * ( 1 - #3 * #2 ) ,5) } }
         { \fp_eval:n { round(#4 * ( 1 - #3 * (1 - #2) ) ,5) } }
         {#1}
      }
  }
\cs_new:Npn \__color_parse_model_hsb_aux:nnnnn #1#2#3#4#5
  { \use:c { __color_parse_model_hsb_ #5 :nnnn } {#1} {#2} {#3} {#4} }
\cs_new:cpn { __color_parse_model_hsb_0:nnnn } #1#2#3#4 { #1 ~ #4 ~ #2 }
\cs_new:cpn { __color_parse_model_hsb_1:nnnn } #1#2#3#4 { #3 ~ #1 ~ #2 }
\cs_new:cpn { __color_parse_model_hsb_2:nnnn } #1#2#3#4 { #2 ~ #1 ~ #4 }
\cs_new:cpn { __color_parse_model_hsb_3:nnnn } #1#2#3#4 { #2 ~ #3 ~ #1 }
\cs_new:cpn { __color_parse_model_hsb_4:nnnn } #1#2#3#4 { #4 ~ #2 ~ #1 }
\cs_new:cpn { __color_parse_model_hsb_5:nnnn } #1#2#3#4 { #1 ~ #2 ~ #3 }
\cs_new:cpn { __color_parse_model_hsb_6:nnnn } #1#2#3#4 { #1 ~ #2 ~ #2 }
\cs_new:Npn \__color_parse_model_HSB:w #1 , #2 , #3 , #4 \s__color_stop
  {
    \exp_args:Neee \__color_parse_model_hsb:nnn
      { \fp_eval:n {#1 / 360} }
      { \fp_eval:n {#2 / 255} }
      { \fp_eval:n {#3 / 255} }
  }
\cs_new:Npn \__color_parse_model_HTML:w #1 , #2 \s__color_stop
  { \__color_parse_model_HTML_aux:w #1 0 0 0 0 0 0 \s__color_stop }
\cs_new:Npn \__color_parse_model_HTML_aux:w #1#2#3#4#5#6#7 \s__color_stop
  {
    { rgb }
    {
      \fp_eval:n { round(\int_from_hex:n {#1#2} / 255,5) } ~
      \fp_eval:n { round(\int_from_hex:n {#3#4} / 255,5) } ~
      \fp_eval:n { round(\int_from_hex:n {#5#6} / 255,5) }
    }
  }
\cs_new:Npn \__color_parse_model_RGB:w #1 , #2 , #3 , #4 \s__color_stop
  {
    { rgb }
    {
      \fp_eval:n { round(#1 / 255,5) } ~
      \fp_eval:n { round(#2 / 255,5) } ~
      \fp_eval:n { round(#3 / 255,5) }
    }
  }
\tl_new:N \l_color_fixed_model_tl
\cs_new_protected:Npn \__color_check_model:N #1
  {
    \tl_if_empty:NF \l_color_fixed_model_tl
      {
        \exp_after:wN \__color_check_model:nn #1
        \tl_if_eq:NNF \l__color_model_tl \l_color_fixed_model_tl
          {
            \__color_convert:VVN \l__color_model_tl \l_color_fixed_model_tl
              \l__color_value_tl
          }
        \tl_set:Nx #1
          { { \l_color_fixed_model_tl } { \l__color_value_tl } }
      }
  }
\cs_new_protected:Npn \__color_check_model:nn #1#2
  {
    \tl_set:Nn \l__color_model_tl {#1}
    \tl_set:Nn \l__color_value_tl {#2}
  }
\cs_new_protected:Npx \__color_select:
  {
    \tl_set:Nx \exp_not:c { l__color_named_ . _tl }
      { \exp_not:N \__color_model:N \exp_not:N \l__color_current_tl }
    \prop_clear:N \exp_not:c { l__color_named_ . _prop }
    \prop_put:NVx \exp_not:c { l__color_named_ . _prop }
      \exp_not:c { l__color_named_ . _tl }
      { \exp_not:N \__color_values:N \exp_not:N \l__color_current_tl }
    \__color_select:N \exp_not:N \l__color_current_tl
  }
\cs_new_protected:Npn \color_select:n #1
  {
    \__color_parse:nN {#1} \l__color_current_tl
    \__color_select:
  }
\cs_new_protected:Npn \color_select:nn #1#2
  {
    \__color_select_main:Nw \l__color_current_tl
      #1 / / \s__color_mark #2 / / \s__color_stop
    \__color_select:
  }
\cs_new_protected:Npn \__color_select_main:Nw
  #1 #2 / #3 / #4 \s__color_mark #5 / #6 / #7 \s__color_stop
  {
    \__color_select:nnN {#2} {#5} #1
    \bool_lazy_or:nnF
      { \tl_if_empty_p:N \l_color_fixed_model_tl }
      { \str_if_eq_p:nV {#2} \l_color_fixed_model_tl }
      { \__color_select_loop:Nw #1 #3 / #4 \s__color_mark #6 / #7 \s__color_stop }
  }
\cs_new_protected:Npn \__color_select_loop:Nw
  #1 #2 / #3 \s__color_mark #4 / #5 \s__color_stop
  {
    \str_if_eq:nVTF {#2} \l_color_fixed_model_tl
      { \__color_select:nnN {#2} {#4} #1 }
      {
        \tl_if_blank:nTF {#2}
          { \exp_after:wN \__color_select_swap:Nnn \exp_after:wN #1 #1 }
          { \__color_select_loop:Nw #1 #3 \s__color_mark #5 \s__color_stop }
      }
  }
\cs_new_protected:Npn \__color_select:nnN #1#2#3
  {
    \cs_if_exist:cTF { __color_parse_model_ #1 :w }
      {
        \tl_set:Nx #3
          { \use:c { __color_parse_model_ #1 :w } #2 , 0 , 0 , 0 , 0 \s__color_stop }
      }
      { \__kernel_msg_error:nnn { color } { unknown-model } {#1} }
  }
\cs_new_protected:Npn \__color_select_swap:Nnn #1#2#3
  {
    \__color_convert:nVnN {#2} \l_color_fixed_model_tl {#3} \l__color_value_tl
    \tl_set:Nx #1
      { { \l_color_fixed_model_tl } { \l__color_value_tl } }
  }
\tl_new:N \l__color_named_tl
\cs_new_protected:Npn \color_set:nn #1#2
  {
    \exp_args:NV \__color_set:nnn
      \l_color_fixed_model_tl {#1} {#2}
  }
\cs_new_protected:Npn \__color_set:nnn #1#2#3
  {
    \tl_clear:N \l_color_fixed_model_tl
    \__color_set:nn {#2} {#3}
    \tl_set:Nn \l_color_fixed_model_tl {#1}
  }
\cs_new_protected:Npn \__color_set:nn #1#2
  {
    \str_if_eq:nnF {#1} { . }
      {
        \__color_parse:nN {#2} \l__color_named_tl
        \tl_clear_new:c { l__color_named_ #1 _tl }
        \tl_set:cx { l__color_named_ #1 _tl }
          { \__color_model:N \l__color_named_tl }
        \prop_clear_new:c { l__color_named_ #1 _prop }
        \prop_put:cvx { l__color_named_ #1 _prop } { l__color_named_ #1 _tl }
          { \__color_values:N \l__color_named_tl }
        \__color_set:nnw {#1} {#2} #2 ! \s__color_stop
      }
  }
\cs_new_protected:Npn \__color_set:nnw #1#2#3 ! #4 \s__color_stop
  {
    \clist_map_inline:nn { cmyk , gray , rgb }
      {
        \prop_get:cnNT { l__color_named_ #3 _prop } {##1} \l__color_internal_tl
          {
            \prop_if_in:cnF { l__color_named_ #1 _prop } {##1}
              {
                \group_begin:
                  \tl_set:cn { l__color_named_ #3 _tl } {##1}
                  \__color_parse:nN {#2} \l__color_internal_tl
                \exp_args:NNNV \group_end:
                \tl_set:Nn \l__color_internal_tl \l__color_internal_tl
                \prop_put:cxx { l__color_named_ #1 _prop }
                  { \__color_model:N \l__color_internal_tl }
                  { \__color_values:N \l__color_internal_tl }
              }
          }
      }
  }
\cs_new_protected:Npn \color_set:nnn #1#2#3
  {
    \str_if_eq:nnF {#1} { . }
      {
        \tl_clear_new:c { l__color_named_ #1 _tl }
        \prop_clear_new:c { l__color_named_ #1 _prop }
        \__color_set_loop:nw {#1} #2 / / \s__color_mark #3 / / \s__color_stop
      }
  }
\cs_new_protected:Npn \__color_set_loop:nw
  #1#2 / #3 \s__color_mark #4 / #5 \s__color_stop
  {
    \tl_if_blank:nF {#2}
      {
        \__color_select:nnN {#2} {#4} \l__color_named_tl
        \tl_set:Nx \l__color_internal_tl { \__color_model:N \l__color_named_tl }
        \tl_if_empty:cT { l__color_named_ #1 _tl }
          { \tl_set_eq:cN { l__color_named_ #1 _tl } \l__color_internal_tl }
        \prop_put:cVx { l__color_named_ #1 _prop } \l__color_internal_tl
          { \__color_values:N \l__color_named_tl }
        \__color_set_loop:nw {#1} #3 \s__color_mark #5 \s__color_stop
      }
  }
\cs_new_protected:Npn \color_set_eq:nn #1#2
  {
    \__color_if_defined:nTF {#2}
      {
        \tl_clear_new:c { l__color_named_ #1 _tl }
        \prop_clear_new:c { l__color_named_ #1 _prop }
        \str_if_eq:nnTF {#2} { . }
          {
            \tl_set:cx { l__color_named_ #1 _tl }
              { \__color_model:N \l__color_current_tl }
            \prop_put:cvx { l__color_named_ #1 _prop } { l__color_named_ #1 _tl }
              { \__color_values:N \l__color_current_tl }
          }
          {
            \tl_set_eq:cc { l__color_named_ #1 _tl } { l__color_named_ #2 _tl }
            \prop_set_eq:cc { l__color_named_ #1 _prop } { l__color_named_ #2 _prop }
          }
      }
      {
        \__kernel_msg_error:nnn { color } { unknown-color } {#2}
      }
  }
\color_set:nnn { black } { gray } { 0 }
\color_set:nnn { white } { gray } { 1 }
\color_set:nnn { cyan }    { cmyk } { 1 , 0 , 0 , 0 }
\color_set:nnn { magenta } { cmyk } { 0 , 1 , 0 , 0 }
\color_set:nnn { yellow }  { cmyk } { 0 , 0 , 1 , 0 }
\color_set:nnn { red }   { rgb } { 1 , 0 , 0 }
\color_set:nnn { green } { rgb } { 0 , 1 , 0 }
\color_set:nnn { blue }  { rgb } { 0 , 0 , 1 }
\prop_new:c { l__color_named_._prop }
\tl_new:c { l__color_named_._tl }
\tl_set:cx { l__color_named_._tl } { \__color_model:N \l__color_current_tl }
\cs_new_protected:Npn \color_export:nnN #1#2#3
  {
    \group_begin:
      \tl_if_exist:cT { c__color_export_ #2 _tl }
        { \tl_set_eq:Nc \l_color_fixed_model_tl { c__color_export_ #2 _tl } }
      \__color_parse:nN {#1} #3
      \__color_export:nN {#2} #3
    \exp_args:NNNV \group_end:
    \tl_set:Nn #3 #3
  }
\cs_new_protected:Npn \color_export:nnnN #1#2#3#4
  {
    \__color_select_main:Nw #4
      #1 / / \s__color_mark #2 / / \s__color_stop
    \__color_export:nN {#3} #4
  }
\cs_new_protected:Npn \__color_export:nN #1#2
  { \exp_after:wN \__color_export:nnnN #2 {#1} #2 }
\cs_new:Npn \__color_export:nnnN #1#2#3#4
  {
    \cs_if_exist_use:cF { __color_export_format_ #3 :nnN }
      {
        \__kernel_msg_error:nnn { color } { unknown-export-format } {#3}
        \use_none:nnn
      }
        {#1} {#2} #4
  }
\cs_new_protected:Npn \__color_export_format_backend:nnN #1#2#3
  { \tl_set:Nn #3 { {#1} {#2} } }
\cs_new_protected:Npn \__color_export:nnnNN #1#2#3#4#5
  {
    \str_if_eq:nnTF {#2} {#1}
      { #5 #4 #3 \s__color_stop }
      {
        \__color_convert:nnnN {#2} {#1} {#3} #4
        \exp_after:wN #5 \exp_after:wN #4
          #4 \s__color_stop
      }
  }
\tl_const:Nn \c__color_export_HTML_tl { rgb }
\tl_const:cn { c__color_export_space-sep-cmyk_tl } { cmyk }
\tl_const:cn { c__color_export_space-sep-rgb_tl } { rgb }
\cs_new_protected:cpx { __color_export_format_space-sep-cmyk:nnN } #1#2#3
  {
    \exp_not:N \__color_export:nnnNN { cmyk } {#1} {#2} #3
      \exp_not:c { __color_export_space-sep-cmyk:Nw }
  }
\cs_new_protected:cpn { __color_export_space-sep-cmyk:Nw } #1#2 \s__color_stop
  { \tl_set:Nx #1 {#2} }
\cs_new_protected:Npn \__color_export_format_HTML:nnN #1#2#3
  { \__color_export:nnnNN { rgb } {#1} {#2}#3 \__color_export_HTML:Nw }
\cs_new_protected:cpx { __color_export_format_space-sep-rgb:nnN } #1#2#3
  {
    \exp_not:N \__color_export:nnnNN { rgb } {#1} {#2} #3
      \exp_not:c { __color_export_space-sep-rgb:Nw }
  }
\cs_new_protected:Npn \__color_export_HTML:Nw #1#2 ~ #3 ~ #4 \s__color_stop
  {
    \tl_set:Nx #1
      {
        \__color_export_HTML:n {#2}
        \__color_export_HTML:n {#3}
        \__color_export_HTML:n {#4}
      }
  }
\cs_new:Npn \__color_export_HTML:n #1
  {
    \fp_compare:nNnTF {#1} = { 0 }
      { 00 }
      { \int_to_Hex:n { \fp_to_int:n { #1 * 255 } } }
  }
\cs_new_protected:cpn { __color_export_space-sep-rgb:Nw } #1#2 \s__color_stop
  { \tl_set:Nx #1 {#2} }
\cs_new_protected:Npn \color_show:n #1
  {
    \msg_show:nnxxxx { LaTeX / color } { show }
      {#1}
      {
        \__color_if_defined:nT {#1}
          {
            \exp_args:Nv \__color_show:n { l__color_named_ #1 _tl }
            \prop_map_function:cN
              { l__color_named_ #1 _prop }
              \msg_show_item_unbraced:nn
          }
      }
      { }
      { }
  }
\cs_new:Npn \__color_show:n #1
  {
    \msg_show_item_unbraced:nn { model } {#1}
  }
\__kernel_msg_new:nnnn { color } { unknown-color }
  { Unknown~color~'#1'. }
  {
    LaTeX~has~been~asked~to~use~a~color~named~'#1',~
    but~this~has~never~been~defined.
  }
\__kernel_msg_new:nnnn { color } { unknown-export-format }
  { Unknown~export~format~'#1'. }
  {
    LaTeX~has~been~asked~to~export~a~color~in~format~'#1',~
    but~this~has~never~been~defined.
  }
\__kernel_msg_new:nnnn { color } { unknown-model }
  { Unknown~color~model~'#1'. }
  {
    LaTeX~has~been~asked~to~use~a~color~model~called~'#1',~
    but~this~model~is~not~set~up.
  }
\__kernel_msg_new:nnn { color } { show }
  {
    The~color~#1~
    \tl_if_empty:nTF {#2}
      { is~undefined. }
      { has~the~properties: #2 }
  }
%% 
%%
%% End of file `l3color.sty'.
