%%
%% This is file `njuvisual.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% njuvisual.dtx  (with options: `package')
%% njuvisual-emblem.dtx  (with options: `color')
%% njuvisual-ai.dtx  (with options: `color')
%% njuvisual-chem.dtx  (with options: `color')
%% njuvisual-cs.dtx  (with options: `color')
%% njuvisual-dii.dtx  (with options: `color')
%% njuvisual-eng.dtx  (with options: `color')
%% njuvisual-physics.dtx  (with options: `color')
%% njuvisual-software.dtx  (with options: `color')
%% 
%% Copyright (C) 2021 - 2022
%% by Nanjing University Linux User Group
%% 
%% This file may be distributed and/or modified under the conditions of
%% the LaTeX Project Public License, either version 1.3c of this license
%% or (at your option) any later version.  The latest version of this
%% license is in:
%% 
%%    http://www.latex-project.org/lppl.txt
%% 
%% and version 1.3 or later is part of all distributions of LaTeX version
%% 2005/12/01 or later.
%% 
%% To produce the documentation run the original source files ending with `.dtx'
%% through XeTeX.
%% 
\NeedsTeXFormat{LaTeX2e}
\GetIdInfo $Id: njuvisual.dtx 0.3.0 2022-12-13 18:00:00
  +0800 NJU LUG <git+nju-lug-email-3104-issue-@yaoge123.cn>$
  {Nanjing University Visual Identity}
\ProvidesExplPackage{njuvisual}
  {\ExplFileDate}{\ExplFileVersion}{\ExplFileDescription}
\RequirePackage { l3keys2e, tikz}
\tl_new:N \l__njuvis_color_a_tl
\tl_new:N \l__njuvis_color_b_tl
\tl_new:N \l__njuvis_dept_tl
\tl_new:N \l__njuvis_curve_tl
\clist_const:Nn \c__njuvis_cmds_clist { emblem, name, motto, spirit }
\clist_const:Nn \c__njuvis_dept_all_clist
  { nju, dii, eng, chin, history, philo, jc, law, nubs, sfs, im, sociology,
    math, physics, astronomy, chem, cs, software, ai, ese, hjxy, sgos,
    as, life, med, sme, hwxy, arch, marxism, art, edu }
\clist_const:Nn \c__njuvis_dept_emblem_clist
  { nju, ai, cs, chem, dii, eng, physics, software }
\clist_const:Nn \c__njuvis_dept_name_clist { nju }
\clist_const:Nn \c__njuvis_dept_color_clist { ai, cs, chem, physics }
\msg_new:nnn { njuvisual } { unsupported-department }
  {
    "#1"~ is~ not~ an~ available~ option~ currently.\\
    Please~ refer~ to~ the~ package~ documentation~ for~ supported~
    departments~ and~ check~ your~ spelling.
  }
\msg_new:nnn { njuvisual } { force-mode }
  { Force~ mode~ on.\\ I~ am~ overwriting~ all~ existing~ commands. }
\msg_new:nnn { njuvisual } { duplicate-command }
  {
    The~ command~ "\string#1"~ is~ already~ defined.\\
    I~ am~ not~ going~ to~ redefine~ it~ anyway.~
    Or~ you~ can~ use~ the~ package~ option~ "force"~
    to~ overwrite~ existing~ definitions.
  }
\keys_define:nn { njuvisual }
  {
    force .value_forbidden:n = true,
    force            .code:n =
      {
        \msg_warning:nn { njuvisual } { force-mode }
        \clist_map_inline:Nn \c__njuvis_cmds_clist
          { \cs_undefine:c { nju ##1 } }
      }
  }
\ProcessKeysOptions { njuvisual }
\keys_define:nn { njuvisual }
  {
    color       .tl_set:N = \l__njuvis_color_a_tl,
    color      .initial:n = default,
    color*      .tl_set:N = \l__njuvis_color_b_tl,
    color*     .initial:n = white,
    department  .tl_set:N = \l__njuvis_dept_tl,
    department .initial:n = nju,
  }
\cs_new_protected:Nn \__njuvis_set_color:
  {
    \str_if_eq:VnTF \l__njuvis_color_a_tl { default }
      {
        \clist_if_in:NVTF \c__njuvis_dept_color_clist \l__njuvis_dept_tl
          { \tl_set:Nn \l__njuvis_color_a_tl
              { \clist_item:cn { c__njuvis_color_ \l__njuvis_dept_tl _clist } { 1 } }
            \tl_set:Nn \l__njuvis_color_b_tl
              { \clist_item:cn { c__njuvis_color_ \l__njuvis_dept_tl _clist } { 2 } } }
          { \tl_set:Nn \l__njuvis_color_a_tl { njuviolet } }
      }
      { \clist_if_in:NVT \c__njuvis_dept_color_clist \l__njuvis_dept_tl
          { \tl_set_eq:NN \l__njuvis_color_b_tl \l__njuvis_color_a_tl } }
  }
\cs_new_protected:Npn \__njuvis_tikz_wrapper:nnn #1#2#3
  {
    \resizebox { #2 } { #3 } {
      \begin{tikzpicture}[y=0.80pt, x=0.80pt, yscale=-1,
          xscale=1, inner~sep=0pt, outer~sep=0pt] #1
      \end{tikzpicture} }
  }
\cs_generate_variant:Nn \__njuvis_tikz_wrapper:nnn { V }
\cs_new_protected:Npn \__njuvis_if_key_value_list:nTF #1
  { \tl_if_in:nnTF {#1} {=} }
\cs_new_protected:Npn \__njuvis_check_cmd:NF #1
  {
    \cs_if_exist:NTF #1
      { \msg_warning:nnn { njuvisual } { duplicate-command } {#1} }
  }
\cs_new:Npn \__njuvis_import_curve:nF #1
  { \file_get:nnNF { njuvisual- #1 .def } { \ExplSyntaxOn } \l__njuvis_curve_tl }
\cs_new:Npn \__njuvis_import_curve:n #1
  { \__njuvis_import_curve:nF {#1} { \BOOM } }
\cs_new_protected:Npn \__njuvis_print:nnnn #1#2#3#4
  {
    \group_begin:
      \__njuvis_if_key_value_list:nTF { #2 }
        {
          \keys_set:nn { njuvisual } { #2 }
          \__njuvis_import_curve:nF { #1 - \l__njuvis_dept_tl }
            {
              \msg_error:nnx { njuvisual }
                { unsupported-department } { \l__njuvis_dept_tl }
            }
          \__njuvis_set_color:
          \__njuvis_tikz_wrapper:Vnn \l__njuvis_curve_tl { #3 } { #4 }
        }
        {
          \tl_set:Nn \l__njuvis_color_a_tl { #2 }
          \__njuvis_import_curve:n { #1 - nju }
          \__njuvis_tikz_wrapper:Vnn \l__njuvis_curve_tl { #3 } { #4 }
        }
    \group_end:
  }
\cs_new_protected:Npn \__njuvis_name:nnnn #1
  {
    \bool_if:NTF #1
      { \__njuvis_print:nnnn { name-en } }
      { \__njuvis_print:nnnn { name-zh } }
  }
\__njuvis_check_cmd:NF \njuname
  {
    \NewDocumentCommand \njuname { s O { njuviolet } m m }
      { \__njuvis_name:nnnn { #1 } { #2 } { #3 } { #4 } }
  }
\__njuvis_check_cmd:NF \njuemblem
  {
    \NewDocumentCommand \njuemblem { O { njuviolet } m m }
      { \__njuvis_print:nnnn { emblem } { #1 } { #2 } { #3 } }
  }
\__njuvis_check_cmd:NF \njumotto
  {
    \NewDocumentCommand \njumotto { O { black } m m }
      { \__njuvis_print:nnnn { motto } { #1 } { #2 } { #3 } }
  }
\__njuvis_check_cmd:NF \njuspirit
  {
    \NewDocumentCommand \njuspirit { O { black } m m }
      { \__njuvis_print:nnnn { spirit } { #1 } { #2 } { #3 } }
  }
\definecolor { njuviolet  } { cmyk } { 0.50, 1   , 0   , 0.40 }
\definecolor { njumagenta } { cmyk } { 0.05, 1   , 0.55, 0    }
\definecolor { njublue    } { cmyk } { 0.80, 0.50, 0   , 0    }
\definecolor { njuyellow  } { cmyk } { 0   , 0.30, 1   , 0    }
\colorlet    { njupurple  } { njuviolet }
\clist_const:Nn \c__njuvis_color_ai_clist { nju-ai-blue, nju-ai-orange }
\definecolor { nju-ai-blue   } { cmyk } { 0.75, 0.65, 0   , 0    }
\definecolor { nju-ai-orange } { cmyk } { 0   , 0.75, 1   , 0    }
\clist_const:Nn \c__njuvis_color_chem_clist { nju-chem-red, white }
\definecolor { nju-chem-red  } { cmyk } { 0.28, 0.95, 0.84, 0    }
\definecolor { nju-chem-gold } { cmyk } { 0.40, 0.42, 0.60, 0    }
\clist_const:Nn \c__njuvis_color_cs_clist { nju-cs-blue, nju-cs-green }
\definecolor { nju-cs-blue  } { cmyk } { 0.89, 0.66, 0.13, 0    }
\definecolor { nju-cs-green } { cmyk } { 0.60, 0.23, 1   , 0    }
\clist_const:Nn \c__njuvis_color_physics_clist { nju-physics-blue, white }
\definecolor { nju-physics-blue } { cmyk } { 0.86, 0.57, 0   , 0    }
\endinput
%%
%% End of file `njuvisual.sty'.
