%%
%% This is file `bearwear.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% bearwear.dtx  (with options: `package')
%% 
%% Copyright (C) 2020 Ulrike Fischer / Bär
%% 
%% 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:
%% 
%%    https://www.latex-project.org/lppl.txt
%% 
%% This file is part of the "bearwear bundle" (The Work in LPPL)
%% and all files in that bundle must be distributed together.
%% 
%% File: bearwear.dtx
\RequirePackage{xparse}
\RequirePackage{tikzlings-bears}
\ProvidesExplPackage {bearwear} {2020-04-21} {0.2}
  {A package for tikz bear fashion}
\ProcessOptions\relax
\tikzset
  {__bearwearreverseclip/.style=
    {insert~path=
      {
       (current~bounding~box.south~west) --  (current~bounding~box.north~west)
       --
       (current~bounding~box.north~east) --  (current~bounding~box.south~east)
       -- cycle
      }
   }
 }

\definecolor{__bearweareuropablue}{RGB}{00,33,99}

\cs_new_protected:Npn \__bearwear_rightarm_path:nn #1 #2 %#1 fill, clip, #2 user
 {
  \path[#1,#2,rotate~around={-50\char_generate:nn{58}{12}(0.525,0.9)}]
    (0.525,0.9) ellipse (0.35~and~0.15);
 }

\cs_new_protected:Npn \__bearwear_leftarm_path:nn #1 #2 %#1 fill, clip, #2 user
 {
   \path[#1,#2,rotate~around={50\char_generate:nn{58}{12}(-0.525,0.9)}]
     (-0.525,0.9) ellipse (0.35~and~0.15);
 }

\cs_new_protected:Npn \__bearwear_body_path:nn #1 #2 %#1 fill, clip, #2 user
 {
   \path[#1,#2] (0,0.75) ellipse (0.55~and~0.65);
 }

\cs_new_protected:Npn \__bearwear_init_path:
  {
    \__bearwear_rightarm_path:nn {}{}
    \__bearwear_leftarm_path:nn  {}{}
    \__bearwear_body_path:nn     {}{}
  }

\cs_new_protected:Npn \__bearwear_set_coordinates:
  {
    \coordinate (beartummy) at (0,0.75);
    \coordinate (bearheart)  at (0.25,0.9);
  }

\cs_new_protected:Npn \__bearwear_clipping_path:
  {
    \bool_if:NTF  \l__bearwear_v_neckline_bool
     {
       \clip  (0, 1.55)     circle (0.5)    [__bearwearreverseclip]; %head
       \clip  (-0.4, 1.55) -- (0.4, 1.55) -- (0,0.8) --cycle[__bearwearreverseclip];
        %v-neck
     }
      {
       \clip  (0, 1.55)     circle (0.53)    [__bearwearreverseclip]; %head
     }
    \clip  (0.425, 0.3)  circle (0.28)   [__bearwearreverseclip];
    \clip  (-0.425, 0.3) circle (0.28)   [__bearwearreverseclip];
    \bool_if:NTF \l__bearwear_t_shirt_bool
     {
       \clip (-1,0.6) --++ (0.45,0)--++(-0.5,5) --cycle[__bearwearreverseclip] ;
       \clip ( 1,0.6) --++ (-0.45,0)--++(0.5,5) --cycle[__bearwearreverseclip] ;
     }
     {
       \clip (-1,0.6) --++ (0.45,0)--++(-0.5,1) --cycle[__bearwearreverseclip] ;
       \clip ( 1,0.6) --++ (-0.45,0)--++(0.5,1) --cycle[__bearwearreverseclip] ;
     }
    \clip(-1,0.5) rectangle (1,1.2);
  }

\cs_new_protected:Npn \__bearwear_shirt_color:
  {
    \bool_if:NF \l__bearwear_muscle_shirt_bool
      {
        \exp_args:Nno \__bearwear_leftarm_path:nn  {fill}{\l__bearwear_leftarm_color_tl}
        \exp_args:Nno \__bearwear_rightarm_path:nn {fill}{\l__bearwear_rightarm_color_tl}
      }
    \exp_args:Nno \__bearwear_body_path:nn     {fill}{\l__bearwear_body_color_tl}
  }

\cs_new_protected:Npn \__bearwear_shirt_pattern:
  {
    \bool_if:NF \l__bearwear_muscle_shirt_bool
      {
        \exp_args:Nno \__bearwear_leftarm_path:nn  {}{\l__bearwear_leftarm_pattern_tl}
        \exp_args:Nno \__bearwear_rightarm_path:nn {}{\l__bearwear_rightarm_pattern_tl}
      }
    \exp_args:Nno \__bearwear_body_path:nn         {}{\l__bearwear_body_pattern_tl}
  }

\cs_new_protected:Npn \__bearwear_shirt_deco:
  {
    \bool_if:NF \l__bearwear_muscle_shirt_bool
      {
        \exp_args:Nno \__bearwear_leftarm_path:nn  {}{\l__bearwear_leftarm_deco_tl}
        \exp_args:Nno \__bearwear_rightarm_path:nn {}{\l__bearwear_rightarm_deco_tl}
      }
    \exp_args:Nno \__bearwear_body_path:nn         {}{\l__bearwear_body_deco_tl}
  }

\bool_new:N \l__bearwear_t_shirt_bool
\bool_new:N \l__bearwear_muscle_shirt_bool
\bool_new:N \l__bearwear_round_neckline_bool

\tl_new:N \l__bearwear_leftarm_color_tl
\tl_new:N \l__bearwear_rightarm_color_tl
\tl_new:N \l__bearwear_body_color_tl

\tl_new:N \l__bearwear_leftarm_pattern_tl
\tl_new:N \l__bearwear_rightarm_pattern_tl
\tl_new:N \l__bearwear_body_pattern_tl
\tl_new:N \l__bearwear_leftarm_deco_tl
\tl_new:N \l__bearwear_rightarm_deco_tl
\tl_new:N \l__bearwear_body_deco_tl
\tl_new:N \l__bearwear_tikzkeys_tl

\keys_define:nn {__bearwear}
 {
   ,leftarm  .tl_set:N = \l__bearwear_leftarm_color_tl
   ,leftarm  .initial:n = {__bearweareuropablue}
   ,leftarm~pattern   .tl_set:N = \l__bearwear_leftarm_pattern_tl
   ,leftarm~deco         .code:n =
      {\tl_set:Nn \l__bearwear_leftarm_deco_tl {path~picture = {#1}}}
   ,rightarm .tl_set:N = \l__bearwear_rightarm_color_tl
   ,rightarm .initial:n = {__bearweareuropablue}
   ,rightarm~pattern   .tl_set:N = \l__bearwear_rightarm_pattern_tl
   ,rightarm~deco         .code:n =
      {\tl_set:Nn \l__bearwear_rightarm_deco_tl {path~picture = {#1}}}
   ,body     .tl_set:N = \l__bearwear_body_color_tl
   ,body     .initial:n = {__bearweareuropablue}
   ,body~pattern   .tl_set:N = \l__bearwear_body_pattern_tl
   ,arms     .meta:n   =  {leftarm={#1},rightarm={#1}}
   ,arms~pattern .meta:n   =  {leftarm~pattern={#1},rightarm~pattern={#1}}
   ,arms~deco .meta:n   =  {leftarm~deco={#1},rightarm~deco={#1}}
   ,shirt    .meta:n   =  {body={#1},leftarm={#1},rightarm={#1}}
   ,shirt~pattern    .meta:n   =
      {body~pattern={#1},leftarm~pattern={#1},rightarm~pattern={#1}}
   ,shirt~deco .meta:n   =
      {body~deco={#1},leftarm~deco={#1},rightarm~deco={#1}}
   ,long~sleeves .bool_set_inverse:N = \l__bearwear_t_shirt_bool
   ,t-shirt    .bool_set:N         = \l__bearwear_t_shirt_bool
   ,muscle~shirt .bool_set:N       = \l__bearwear_muscle_shirt_bool
   ,body~deco         .code:n =
      {\tl_set:Nn \l__bearwear_body_deco_tl {path~picture = {#1}}}
   ,round~neckline .bool_set_inverse:N       = \l__bearwear_v_neckline_bool
   ,v-neckline .bool_set:N   = \l__bearwear_v_neckline_bool
 }

\NewDocumentCommand\bearwearsetup { m }
 {
    \keys_set:nn { __bearwear } {#1}
 }
\NewDocumentCommand\bearwear { O {} }
  {
    \begin{scope}[even~odd~rule]
     % handle keys
     \keys_set_known:nnN { __bearwear } {#1}\l__bearwear_tikzkeys_tl
     \exp_args:No\tikzset{\l__bearwear_tikzkeys_tl}
     \__bearwear_init_path:
     \__bearwear_set_coordinates:
     \__bearwear_clipping_path:
     \__bearwear_shirt_color:
     \__bearwear_shirt_pattern:
     \__bearwear_shirt_deco:
    \end{scope}
  }

\NewDocumentCommand\bearwearlogo {} {{
  \normalfont\fontencoding{T1}\fontfamily{AlegreyaSans-LF}\selectfont
   BearWear
   \raisebox{0.8ex}[0pt][0pt]{
     %\textcircled{
       \begin{tikzpicture}[baseline={(0,0.03)},scale=\fp_eval:n{\f@size/100}]
           \bear;
           \bearwear[body~deco={\node[text=white] at (beartummy)
              {\fontsize{\fp_eval:n{\f@size/20}pt}{\fp_eval:n{\f@size/20}pt}
                \sffamily
                BearWear};}]
       \end{tikzpicture}}}}%}
%% 
%%
%% End of file `bearwear.sty'.
