%%
%% This is file `tikzlibrarycalligraphy.code.tex',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% spath3_code.dtx  (with options: `calligraphy')
%% ----------------------------------------------------------------
%% spath3 --- Functions for manipulating PGF soft paths
%% E-mail: loopspace@mathforge.org
%% Released under the LaTeX Project Public License v1.3c or later
%% See http://www.latex-project.org/lppl.txt
%% ----------------------------------------------------------------
%% 
\RequirePackage{spath3}
\ExplSyntaxOn

\tl_new:N \l__cal_tmpa_tl
\tl_new:N \l__cal_tmpb_tl
\tl_new:N \l__cal_tmp_path_tl
\tl_new:N \l__cal_tmp_rpath_tl
\tl_new:N \l__cal_tmp_rpathb_tl
\tl_new:N \l__cal_tmp_patha_tl

\seq_new:N \l__cal_tmpa_seq

\int_new:N \l__cal_tmpa_int
\int_new:N \l__cal_tmpb_int
\int_new:N \g__cal_path_component_int
\int_new:N \g__cal_label_int

\fp_new:N \l__cal_tmpa_fp
\fp_new:N \l__cal_tmpb_fp
\fp_new:N \l__cal_tmpc_fp
\fp_new:N \l__cal_tmpd_fp
\fp_new:N \l__cal_tmpe_fp

\dim_new:N \l__cal_tmpa_dim
\dim_new:N \l__cal_tmpb_dim
\dim_new:N \l__cal_tmpc_dim
\dim_new:N \l__cal_tmpd_dim
\dim_new:N \l__cal_tmpe_dim
\dim_new:N \l__cal_tmpf_dim
\dim_new:N \l__cal_tmpg_dim
\dim_new:N \l__cal_tmph_dim

\bool_new:N \l__cal_annotate_bool
\bool_new:N \l__cal_taper_start_bool
\bool_new:N \l__cal_taper_end_bool
\bool_new:N \l__cal_taperable_bool

\dim_new:N \l__cal_taper_width_dim
\dim_new:N \l__cal_line_width_dim

\bool_set_true:N \l__cal_taper_start_bool
\bool_set_true:N \l__cal_taper_end_bool

\cs_generate_variant:Nn \tl_put_right:Nn {Nv}

\msg_new:nnn { calligraphy } { undefined pen } { The~ pen~ "#1"~ is~ not~ defined. }
\tikzset{
  define~pen/.code={
    \tikzset{pen~name=#1}
    \pgf@relevantforpicturesizefalse
    \tikz@addmode{
      \pgfsyssoftpath@getcurrentpath\l__cal_tmpa_tl
      \spath_components_to_seq:NV \l__cal_tmpa_seq \l__cal_tmpa_tl
      \seq_gclear_new:c {g__cal_pen_\pgfkeysvalueof{/tikz/pen~name}_seq}
      \seq_gset_eq:cN
      {g__cal_pen_\pgfkeysvalueof{/tikz/pen~name}_seq} \l__cal_tmpa_seq
      \pgfusepath{discard}%
    }
  },
  define~pen/.default={default},
  use~pen/.code={
    \tikzset{pen~name=#1}
    \int_gzero:N \g__cal_path_component_int
    \cs_set_eq:NN \pgfpathmoveto \cal_moveto:n
    \tikz@addmode{
      \pgfsyssoftpath@getcurrentpath\l__cal_tmpa_tl
      \spath_components_to_seq:NV \l__cal_tmpa_seq \l__cal_tmpa_tl
      \tl_if_exist:cTF {g__cal_pen_\pgfkeysvalueof{/tikz/pen~name}_seq}
      {
        \cal_path_create:Nc \l__cal_tmpa_seq
        {g__cal_pen_\pgfkeysvalueof{/tikz/pen~name}_seq}
      }
      {
        \msg_warning:nnx { calligraphy } { undefined pen }
        { \pgfkeysvalueof{/tikz/pen~name} }
      }
    }
  },
  use~pen/.default={default},
  pen~name/.initial={default},
  copperplate/.style={pen~name=copperplate},
  pen~colour/.initial={black},
  weight/.is~choice,
  weight/heavy/.style={
    line~width=\pgfkeysvalueof{/tikz/heavy~line~width},
    taper~width=\pgfkeysvalueof{/tikz/light~line~width},
  },
  weight/light/.style={
    line~width=\pgfkeysvalueof{/tikz/light~line~width},
    taper~width=0pt,
  },
  heavy/.style={
    weight=heavy
  },
  light/.style={
    weight=light
  },
  heavy~line~width/.initial=2pt,
  light~line~width/.initial=1pt,
  taper/.is~choice,
  taper/.default=both,
  taper/none/.style={
    taper~start=false,
    taper~end=false,
  },
  taper/both/.style={
    taper~start=true,
    taper~end=true,
  },
  taper/start/.style={
    taper~start=true,
    taper~end=false,
  },
  taper/end/.style={
    taper~start=false,
    taper~end=true,
  },
  taper~start/.code={
    \tl_if_eq:nnTF {#1} {true}
    {
      \bool_set_true:N \l__cal_taper_start_bool
    }
    {
      \bool_set_false:N \l__cal_taper_start_bool
    }
  },
  taper~start/.default={true},
  taper~end/.code={
    \tl_if_eq:nnTF {#1} {true}
    {
      \bool_set_true:N \l__cal_taper_end_bool
    }
    {
      \bool_set_false:N \l__cal_taper_end_bool
    }
  },
  taper~end/.default={true},
  taper~width/.code={\dim_set:Nn \l__cal_taper_width_dim {#1}},
  nib~style/.code~2~args={
    \tl_clear_new:c {l__cal_nib_style_#1}
    \tl_set:cn {l__cal_nib_style_#1} {#2}
  },
  stroke~style/.code~2~args={
    \tl_clear_new:c {l__cal_stroke_style_#1}
    \tl_set:cn {l__cal_stroke_style_#1} {#2}
  },
  this~stroke~style/.code={
    \tl_clear_new:c
    {l__cal_stroke_inline_style_ \int_use:N \g__cal_path_component_int}
    \tl_set:cn
    {l__cal_stroke_inline_style_ \int_use:N \g__cal_path_component_int} {#1}
  },
  annotate/.style={
    annotate~if,
    annotate~reset,
    annotation~style/.update~value={#1},
  },
  annotate~if/.default={true},
  annotate~if/.code={
    \tl_if_eq:nnTF {#1} {true}
    {
      \bool_set_true:N \l__cal_annotate_bool
    }
    {
      \bool_set_false:N \l__cal_annotate_bool
    }
  },
  annotate~reset/.code={
    \int_gzero:N \g__cal_label_int
  },
  annotation~style/.initial={draw,->},
  annotation~shift/.initial={(0,1ex)},
  every~annotation~node/.initial={anchor=south~west},
  annotation~node~style/.code~2~args={
    \tl_clear_new:c {l__cal_annotation_style_ #1 _tl}
    \tl_set:cn {l__cal_annotation_style_ #1 _tl}{#2}
  },
  tl~use:N/.code={
    \exp_args:NV \pgfkeysalso #1
  },
  tl~use:c/.code={
    \tl_if_exist:cT {#1}
    {
      \exp_args:Nv \pgfkeysalso {#1}
    }
  },
  /handlers/.update~style/.code={
    \tl_if_eq:nnF {#1} {\pgfkeysnovalue}
    {
      \pgfkeys{\pgfkeyscurrentpath/.code=\pgfkeysalso{#1}}
    }
  },
  /handlers/.update~value/.code={
    \tl_if_eq:nnF {#1} {\pgfkeysnovalue}
    {
      \pgfkeyssetvalue{\pgfkeyscurrentpath}{#1}
    }
  },
}
\NewDocumentCommand \pen { O{} }
{
  \path[define~ pen,every~ calligraphy~ pen/.try,#1]
}

\NewDocumentCommand \definepen { O{} }
{
  \tikz \path[define~ pen,every~ calligraphy~ pen/.try,#1]
}

\NewDocumentCommand \calligraphy { O{} }
{
  \path[use~ pen,every~ calligraphy/.try,#1]
}
\cs_new_protected_nopar:Npn \cal_path_create:NN #1#2
{
  \int_zero:N \l__cal_tmpa_int
  \seq_map_inline:Nn #1
  {
    \int_compare:nT {\tl_count:n {##1} > 3}
    {

      \int_incr:N \l__cal_tmpa_int
      \int_zero:N \l__cal_tmpb_int

      \tl_set:Nn \l__cal_tmp_path_tl {##1}
      \spath_open:N \l__cal_tmp_path_tl
      \spath_reverse:NV \l__cal_tmp_rpath_tl \l__cal_tmp_path_tl

      \seq_map_inline:Nn #2
      {
        \int_incr:N \l__cal_tmpb_int
        \group_begin:
        \pgfsys@beginscope
        \cal_apply_style:c {l__cal_stroke_style_ \int_use:N \l__cal_tmpa_int}
        \cal_apply_style:c {l__cal_stroke_inline_style_ \int_use:N \l__cal_tmpa_int}
        \cal_apply_style:c {l__cal_nib_style_ \int_use:N \l__cal_tmpb_int}

        \spath_initialpoint:Nn \l__cal_tmpa_tl {####1}
        \tl_set_eq:NN \l__cal_tmp_patha_tl \l__cal_tmp_path_tl
        \spath_translate:NV \l__cal_tmp_patha_tl \l__cal_tmpa_tl

        \int_compare:nTF {\tl_count:n {####1} == 3}
        {
          \cal_at_least_three:N \l__cal_tmp_patha_tl
          \spath_protocol_path:V \l__cal_tmp_patha_tl

          \tikz@options
          \dim_set:Nn \l__cal_line_width_dim {\pgflinewidth}
          \cal_maybe_taper:N \l__cal_tmp_patha_tl
        }
        {
          \spath_weld:Nn \l__cal_tmp_patha_tl {####1}
          \spath_weld:NV \l__cal_tmp_patha_tl \l__cal_tmp_rpath_tl
          \spath_reverse:Nn \l__cal_tmp_rpathb_tl {####1}
          \spath_weld:NV \l__cal_tmp_patha_tl \l__cal_tmp_rpathb_tl

          \tl_clear:N \l__cal_tmpa_tl
          \tl_set:Nn \l__cal_tmpa_tl
          {
            fill=\pgfkeysvalueof{/tikz/pen~colour},
            draw=none
          }
          \tl_if_exist:cT  {l__cal_stroke_style_ \int_use:N \l__cal_tmpa_int}
          {
            \tl_put_right:Nv \l__cal_tmpa_tl
            {l__cal_stroke_style_ \int_use:N \l__cal_tmpa_int}
          }
          \tl_if_exist:cT  {l__cal_stroke_inline_style_ \int_use:N \l__cal_tmpa_int}
          {
            \tl_put_right:Nn \l__cal_tmpa_tl {,}
            \tl_put_right:Nv \l__cal_tmpa_tl
            {l__cal_stroke_inline_style_ \int_use:N \l__cal_tmpa_int}
          }
          \tl_if_exist:cT  {l__cal_nib_style_ \int_use:N \l__cal_tmpb_int}
          {
            \tl_put_right:Nn \l__cal_tmpa_tl {,}
            \tl_put_right:Nv \l__cal_tmpa_tl
            {l__cal_nib_style_ \int_use:N \l__cal_tmpb_int}
          }
          \spath_tikz_path:VV \l__cal_tmpa_tl \l__cal_tmp_patha_tl
        }
        \pgfsys@endscope
        \group_end:
      }

      \bool_if:NT \l__cal_annotate_bool
      {
        \seq_get_right:NN #2 \l__cal_tmpa_tl
        \spath_finalpoint:NV \l__cal_tmpa_tl \l__cal_tmpa_tl
        \spath_translate:NV \l__cal_tmp_path_tl \l__cal_tmpa_tl
        \tikz@scan@one@point
        \pgfutil@firstofone
        \pgfkeysvalueof{/tikz/annotation~shift}

        \spath_translate:Nnn \l__cal_tmp_path_tl {\pgf@x} {\pgf@y}

        \pgfkeysgetvalue{/tikz/annotation~style}{\l__cal_tmpa_tl}
        \spath_tikz_path:VV \l__cal_tmpa_tl \l__cal_tmp_path_tl

        \spath_finalpoint:NV \l__cal_tmpa_tl \l__cal_tmp_path_tl

        \exp_last_unbraced:NV \pgfqpoint \l__cal_tmpa_tl
        \begin{scope}[reset~ cm]
        \node[
          every~annotation~node/.try,
          tl~use:c = {l__cal_annotation_style_ \int_use:N \l__cal_tmpa_int _tl}
        ] at (\pgf@x,\pgf@y) {\int_use:N \l__cal_tmpa_int};
        \end{scope}
      }
    }
  }
}
\cs_generate_variant:Nn \cal_path_create:NN {Nc}
\cs_new_eq:NN \cal_orig_moveto:n \pgfpathmoveto
\cs_new_nopar:Npn \cal_moveto:n #1
{
  \int_gincr:N \g__cal_path_component_int
  \cal_orig_moveto:n {#1}
}
\cs_new_nopar:Npn \cal_apply_style:N #1
{
  \tl_if_exist:NT #1 {
    \exp_args:NV \tikzset #1
  }
}
\cs_generate_variant:Nn \cal_apply_style:N {c}
\cs_new_protected_nopar:Npn \cal_at_least_three:Nn #1#2
{
  \spath_reallength:Nn \l__cal_tmpa_int {#2}
  \tl_clear:N \l__cal_tmpb_tl
  \tl_set:Nn \l__cal_tmpb_tl {#2}
  \int_compare:nTF {\l__cal_tmpa_int = 1}
  {
    \spath_split_at:Nn \l__cal_tmpb_tl {2/3}
    \spath_split_at:Nn \l__cal_tmpb_tl {1/2}
  }
  {
    \int_compare:nT {\l__cal_tmpa_int = 2}
    {
      \spath_split_at:Nn \l__cal_tmpb_tl {1.5}
      \spath_split_at:Nn \l__cal_tmpb_tl {.5}
    }
  }
  \tl_set_eq:NN #1 \l__cal_tmpb_tl
}
\cs_generate_variant:Nn \cal_at_least_three:Nn {NV}
\cs_new_protected_nopar:Npn \cal_at_least_three:N #1
{
  \cal_at_least_three:NV #1#1
}
\cs_generate_variant:Nn \cal_at_least_three:N {c}
\cs_new_protected_nopar:Npn \cal_maybe_taper:N #1
{
  \tl_set_eq:NN \l__cal_tmpa_tl #1

  \bool_if:NT \l__cal_taper_start_bool
  {

    \dim_set:Nn \l__cal_tmpa_dim {\tl_item:Nn \l__cal_tmpa_tl {2}}
    \dim_set:Nn \l__cal_tmpb_dim {\tl_item:Nn \l__cal_tmpa_tl {3}}
    \tl_set:Nx \l__cal_tmpb_tl {\tl_item:Nn \l__cal_tmpa_tl {4}}

    \tl_case:NnF \l__cal_tmpb_tl
    {
      \c_spath_lineto_tl
      {

        \bool_set_true:N \l__cal_taperable_bool
        \dim_set:Nn \l__cal_tmpg_dim {\tl_item:Nn \l__cal_tmpa_tl {5}}
        \dim_set:Nn \l__cal_tmph_dim {\tl_item:Nn \l__cal_tmpa_tl {6}}
        \dim_set:Nn \l__cal_tmpc_dim {(2\l__cal_tmpa_dim + \l__cal_tmpg_dim)/3}
        \dim_set:Nn \l__cal_tmpd_dim {(2\l__cal_tmpb_dim + \l__cal_tmph_dim)/3}
        \dim_set:Nn \l__cal_tmpe_dim {(\l__cal_tmpa_dim + 2\l__cal_tmpg_dim)/3}
        \dim_set:Nn \l__cal_tmpf_dim {(\l__cal_tmpb_dim + 2\l__cal_tmph_dim)/3}
        \prg_replicate:nn {4}
        {
          \tl_set:Nx \l__cal_tmpa_tl {\tl_tail:N \l__cal_tmpa_tl}
        }
        \tl_put_left:NV \l__cal_tmpa_tl \c_spath_moveto_tl
      }
      \c_spath_curvetoa_tl
      {
        \bool_set_true:N \l__cal_taperable_bool
        \dim_set:Nn \l__cal_tmpc_dim {\tl_item:Nn \l__cal_tmpa_tl {5}}
        \dim_set:Nn \l__cal_tmpd_dim {\tl_item:Nn \l__cal_tmpa_tl {6}}
        \dim_set:Nn \l__cal_tmpe_dim {\tl_item:Nn \l__cal_tmpa_tl {8}}
        \dim_set:Nn \l__cal_tmpf_dim {\tl_item:Nn \l__cal_tmpa_tl {9}}
        \dim_set:Nn \l__cal_tmpg_dim {\tl_item:Nn \l__cal_tmpa_tl {11}}
        \dim_set:Nn \l__cal_tmph_dim {\tl_item:Nn \l__cal_tmpa_tl {12}}
        \prg_replicate:nn {10}
        {
          \tl_set:Nx \l__cal_tmpa_tl {\tl_tail:N \l__cal_tmpa_tl}
        }
        \tl_put_left:NV \l__cal_tmpa_tl \c_spath_moveto_tl
      }
    }
    {
      \bool_set_false:N \l__cal_taperable_bool
    }

    \bool_if:NT \l__cal_taperable_bool
    {
      \__cal_taper_aux:
    }

  }

  \bool_if:NT \l__cal_taper_end_bool
  {

    \dim_set:Nn \l__cal_tmpa_dim {\tl_item:Nn \l__cal_tmpa_tl {-2}}
    \dim_set:Nn \l__cal_tmpb_dim {\tl_item:Nn \l__cal_tmpa_tl {-1}}
    \tl_set:Nx \l__cal_tmpb_tl {\tl_item:Nn \l__cal_tmpa_tl {-3}}

    \tl_case:NnF \l__cal_tmpb_tl
    {
      \c_spath_lineto_tl
      {

        \bool_set_true:N \l__cal_taperable_bool
        \dim_set:Nn \l__cal_tmpg_dim {\tl_item:Nn \l__cal_tmpa_tl {-5}}
        \dim_set:Nn \l__cal_tmph_dim {\tl_item:Nn \l__cal_tmpa_tl {-4}}
        \dim_set:Nn \l__cal_tmpc_dim {(2\l__cal_tmpa_dim + \l__cal_tmpg_dim)/3}
        \dim_set:Nn \l__cal_tmpd_dim {(2\l__cal_tmpb_dim + \l__cal_tmph_dim)/3}
        \dim_set:Nn \l__cal_tmpe_dim {(\l__cal_tmpa_dim + 2\l__cal_tmpg_dim)/3}
        \dim_set:Nn \l__cal_tmpf_dim {(\l__cal_tmpb_dim + 2\l__cal_tmph_dim)/3}
        \tl_reverse:N \l__cal_tmpa_tl
        \prg_replicate:nn {3}
        {
          \tl_set:Nx \l__cal_tmpa_tl {\tl_tail:N \l__cal_tmpa_tl}
        }
        \tl_reverse:N \l__cal_tmpa_tl
      }
      \c_spath_curveto_tl
      {
        \bool_set_true:N \l__cal_taperable_bool
        \dim_set:Nn \l__cal_tmpc_dim {\tl_item:Nn \l__cal_tmpa_tl {-5}}
        \dim_set:Nn \l__cal_tmpd_dim {\tl_item:Nn \l__cal_tmpa_tl {-4}}
        \dim_set:Nn \l__cal_tmpe_dim {\tl_item:Nn \l__cal_tmpa_tl {-8}}
        \dim_set:Nn \l__cal_tmpf_dim {\tl_item:Nn \l__cal_tmpa_tl {-7}}
        \dim_set:Nn \l__cal_tmpg_dim {\tl_item:Nn \l__cal_tmpa_tl {-11}}
        \dim_set:Nn \l__cal_tmph_dim {\tl_item:Nn \l__cal_tmpa_tl {-10}}
        \tl_reverse:N \l__cal_tmpa_tl
        \prg_replicate:nn {9}
        {
          \tl_set:Nx \l__cal_tmpa_tl {\tl_tail:N \l__cal_tmpa_tl}
        }
        \tl_reverse:N \l__cal_tmpa_tl
      }
    }
    {
      \bool_set_false:N \l__cal_taperable_bool
    }

    \bool_if:NT \l__cal_taperable_bool
    {
      \__cal_taper_aux:
    }

  }

  \pgfsyssoftpath@setcurrentpath\l__cal_tmpa_tl
  \pgfsetstrokecolor{\pgfkeysvalueof{/tikz/pen~colour}}
  \pgfusepath{stroke}

}
\cs_new_protected_nopar:Npn \__cal_taper_aux:
{
  \tl_clear:N \l__cal_tmpb_tl
  \tl_put_right:NV \l__cal_tmpb_tl \c_spath_moveto_tl

  \fp_set:Nn \l__cal_tmpa_fp
  {
    \l__cal_tmpd_dim - \l__cal_tmpb_dim
  }
  \fp_set:Nn \l__cal_tmpb_fp
  {
    \l__cal_tmpa_dim - \l__cal_tmpc_dim
  }
  \fp_set:Nn \l__cal_tmpe_fp
  {
    (\l__cal_tmpa_fp^2 + \l__cal_tmpb_fp^2)^.5
  }

  \fp_set:Nn \l__cal_tmpa_fp
  {
    .5*\l__cal_taper_width_dim
    *
    \l__cal_tmpa_fp / \l__cal_tmpe_fp
  }
  \fp_set:Nn \l__cal_tmpb_fp
  {
    .5*\l__cal_taper_width_dim
    *
    \l__cal_tmpb_fp / \l__cal_tmpe_fp
  }

  \fp_set:Nn \l__cal_tmpc_fp
  {
    \l__cal_tmph_dim - \l__cal_tmpf_dim
  }
  \fp_set:Nn \l__cal_tmpd_fp
  {
    \l__cal_tmpe_dim - \l__cal_tmpg_dim
  }
  \fp_set:Nn \l__cal_tmpe_fp
  {
    (\l__cal_tmpc_fp^2 + \l__cal_tmpd_fp^2)^.5
  }

  \fp_set:Nn \l__cal_tmpc_fp
  {
    .5*\l__cal_line_width_dim
    *
    \l__cal_tmpc_fp / \l__cal_tmpe_fp
  }
  \fp_set:Nn \l__cal_tmpd_fp
  {
    .5*\l__cal_line_width_dim
    *
    \l__cal_tmpd_fp / \l__cal_tmpe_fp
  }

  \tl_put_right:Nx \l__cal_tmpb_tl
  {
    {\dim_eval:n { \fp_to_dim:N \l__cal_tmpa_fp + \l__cal_tmpa_dim}}
    {\dim_eval:n { \fp_to_dim:N \l__cal_tmpb_fp + \l__cal_tmpb_dim}}
  }

  \tl_put_right:NV \l__cal_tmpb_tl \c_spath_curvetoa_tl

  \tl_put_right:Nx \l__cal_tmpb_tl
  {
    {\dim_eval:n { \fp_to_dim:N \l__cal_tmpa_fp + \l__cal_tmpc_dim}}
    {\dim_eval:n { \fp_to_dim:N \l__cal_tmpb_fp + \l__cal_tmpd_dim}}
  }

  \tl_put_right:NV \l__cal_tmpb_tl \c_spath_curvetob_tl

  \tl_put_right:Nx \l__cal_tmpb_tl
  {
    {\dim_eval:n { \fp_to_dim:N \l__cal_tmpc_fp + \l__cal_tmpe_dim}}
    {\dim_eval:n { \fp_to_dim:N \l__cal_tmpd_fp + \l__cal_tmpf_dim}}
  }

  \tl_put_right:NV \l__cal_tmpb_tl \c_spath_curveto_tl

  \tl_put_right:Nx \l__cal_tmpb_tl
  {
    {\dim_eval:n { \fp_to_dim:N \l__cal_tmpc_fp + \l__cal_tmpg_dim}}
    {\dim_eval:n { \fp_to_dim:N \l__cal_tmpd_fp + \l__cal_tmph_dim}}
  }

  \tl_put_right:NV \l__cal_tmpb_tl \c_spath_curvetoa_tl

  \tl_put_right:Nx \l__cal_tmpb_tl
  {
    {
      \dim_eval:n
      {
        \fp_to_dim:N \l__cal_tmpc_fp + \l__cal_tmpg_dim
        - \fp_to_dim:n{ 1.32 * \l__cal_tmpd_fp
        }
      }
    }
    {
      \dim_eval:n
      {
        \fp_to_dim:N \l__cal_tmpd_fp + \l__cal_tmph_dim
        + \fp_to_dim:n {1.32* \l__cal_tmpc_fp
        }
      }
    }
  }

  \tl_put_right:NV \l__cal_tmpb_tl \c_spath_curvetob_tl

  \tl_put_right:Nx \l__cal_tmpb_tl
  {
    {
      \dim_eval:n
      {
        -\fp_to_dim:N \l__cal_tmpc_fp + \l__cal_tmpg_dim
        - \fp_to_dim:n {1.32 * \l__cal_tmpd_fp
        }
      }
    }
    {
      \dim_eval:n
      {
        -\fp_to_dim:N \l__cal_tmpd_fp + \l__cal_tmph_dim
        + \fp_to_dim:n {1.32 * \l__cal_tmpc_fp
        }
      }
    }
  }

  \tl_put_right:NV \l__cal_tmpb_tl \c_spath_curveto_tl

  \tl_put_right:Nx \l__cal_tmpb_tl
  {
    {\dim_eval:n { -\fp_to_dim:N \l__cal_tmpc_fp + \l__cal_tmpg_dim}}
    {\dim_eval:n { -\fp_to_dim:N \l__cal_tmpd_fp + \l__cal_tmph_dim}}
  }

  \tl_put_right:NV \l__cal_tmpb_tl \c_spath_curvetoa_tl

  \tl_put_right:Nx \l__cal_tmpb_tl
  {
    {\dim_eval:n { -\fp_to_dim:N \l__cal_tmpc_fp + \l__cal_tmpe_dim}}
    {\dim_eval:n { -\fp_to_dim:N \l__cal_tmpd_fp + \l__cal_tmpf_dim}}
  }

  \tl_put_right:NV \l__cal_tmpb_tl \c_spath_curvetob_tl

  \tl_put_right:Nx \l__cal_tmpb_tl
  {
    {\dim_eval:n { -\fp_to_dim:N \l__cal_tmpa_fp + \l__cal_tmpc_dim}}
    {\dim_eval:n { -\fp_to_dim:N \l__cal_tmpb_fp + \l__cal_tmpd_dim}}
  }

  \tl_put_right:NV \l__cal_tmpb_tl \c_spath_curveto_tl

  \tl_put_right:Nx \l__cal_tmpb_tl
  {
    {\dim_eval:n { -\fp_to_dim:N \l__cal_tmpa_fp + \l__cal_tmpa_dim}}
    {\dim_eval:n { -\fp_to_dim:N \l__cal_tmpb_fp + \l__cal_tmpb_dim}}
  }

  \tl_put_right:NV \l__cal_tmpb_tl \c_spath_curvetoa_tl

  \tl_put_right:Nx \l__cal_tmpb_tl
  {
    {
      \dim_eval:n
      {
        -\fp_to_dim:N \l__cal_tmpa_fp + \l__cal_tmpa_dim
        + \fp_to_dim:n{ 1.32 * \l__cal_tmpb_fp}
      }
    }
    {
      \dim_eval:n
      {
        -\fp_to_dim:N \l__cal_tmpb_fp + \l__cal_tmpb_dim
        - \fp_to_dim:n {1.32* \l__cal_tmpa_fp}
      }
    }
  }

  \tl_put_right:NV \l__cal_tmpb_tl \c_spath_curvetob_tl

  \tl_put_right:Nx \l__cal_tmpb_tl
  {
    {
      \dim_eval:n
      {
        \fp_to_dim:N \l__cal_tmpa_fp + \l__cal_tmpa_dim
        + \fp_to_dim:n {1.32 * \l__cal_tmpb_fp}
      }
    }
    {
      \dim_eval:n
      {
        \fp_to_dim:N \l__cal_tmpb_fp + \l__cal_tmpb_dim
        - \fp_to_dim:n {1.32 * \l__cal_tmpa_fp}
      }
    }
  }

  \tl_put_right:NV \l__cal_tmpb_tl \c_spath_curveto_tl

  \tl_put_right:Nx \l__cal_tmpb_tl
  {
    {\dim_eval:n { \fp_to_dim:N \l__cal_tmpa_fp + \l__cal_tmpa_dim}}
    {\dim_eval:n { \fp_to_dim:N \l__cal_tmpb_fp + \l__cal_tmpb_dim}}
  }

  \pgfsyssoftpath@setcurrentpath\l__cal_tmpb_tl
  \pgfsetfillcolor{\pgfkeysvalueof{/tikz/pen~colour}}
  \pgfusepath{fill}
}
\tl_set:Nn \l__cal_tmpa_tl {\pgfsyssoftpath@movetotoken{0pt}{0pt}}
\spath_components_to_seq:NV \l__cal_tmpa_seq \l__cal_tmpa_tl
\seq_gclear_new:N \g__cal_pen_copperplate_seq
\seq_gset_eq:NN \g__cal_pen_copperplate_seq \l__cal_tmpa_seq
\DeclareDocumentCommand \CopperplatePath { m }
{
  \spath_components_to_seq:NV \l__cal_tmpa_seq #1
  \cal_path_create:NN \l__cal_tmpa_seq \g__cal_pen_copperplate_seq
}
\ExplSyntaxOff
\expandafter\ifx\csname pgfdeclaredecoration\endcsname\relax
\else
\pgfdeclaredecoration{calligraphic brace}{brace}%
{%
  \state{brace}[width=+\pgfdecoratedremainingdistance,next state=final]%
  {%
    \pgfsyssoftpath@setcurrentpath{\pgfutil@empty}%
    \pgfpathmoveto{\pgfpointorigin}%
    \pgfpathcurveto%
    {%
      \pgfqpoint%
      {.15\pgfdecorationsegmentamplitude}%
      {.3\pgfdecorationsegmentamplitude}%
    }%
    {%
      \pgfqpoint%
      {.5\pgfdecorationsegmentamplitude}%
      {.5\pgfdecorationsegmentamplitude}%
    }%
    {%
      \pgfqpoint%
      {\pgfdecorationsegmentamplitude}%
      {.5\pgfdecorationsegmentamplitude}%
    }%
    {%
      \pgftransformxshift%
      {+\pgfdecorationsegmentaspect\pgfdecoratedremainingdistance}%
      \pgfpathlineto%
      {%
        \pgfqpoint%
        {-\pgfdecorationsegmentamplitude}%
        {.5\pgfdecorationsegmentamplitude}%
      }%
      \pgfpathcurveto
      {%
        \pgfqpoint%
        {-.5\pgfdecorationsegmentamplitude}%
        {.5\pgfdecorationsegmentamplitude}%
      }%
      {%
        \pgfqpoint%
        {-.15\pgfdecorationsegmentamplitude}%
        {.7\pgfdecorationsegmentamplitude}%
      }%
      {%
        \pgfqpoint%
        {0\pgfdecorationsegmentamplitude}%
        {1\pgfdecorationsegmentamplitude}%
      }%
      \pgfpathmoveto%
      {%
        \pgfqpoint%
        {0\pgfdecorationsegmentamplitude}%
        {1\pgfdecorationsegmentamplitude}%
      }%
      \pgfpathcurveto%
      {%
        \pgfqpoint%
        {.15\pgfdecorationsegmentamplitude}%
        {.7\pgfdecorationsegmentamplitude}%
      }%
      {%
        \pgfqpoint%
        {.5\pgfdecorationsegmentamplitude}%
        {.5\pgfdecorationsegmentamplitude}%
      }%
      {%
        \pgfqpoint%
        {\pgfdecorationsegmentamplitude}%
        {.5\pgfdecorationsegmentamplitude}%
      }%
    }%
    {%
      \pgftransformxshift{+\pgfdecoratedremainingdistance}%
      \pgfpathlineto%
      {%
        \pgfqpoint%
        {-\pgfdecorationsegmentamplitude}%
        {.5\pgfdecorationsegmentamplitude}%
      }%
      \pgfpathcurveto%
      {%
        \pgfqpoint%
        {-.5\pgfdecorationsegmentamplitude}%
        {.5\pgfdecorationsegmentamplitude}%
      }%
      {%
        \pgfqpoint%
        {-.15\pgfdecorationsegmentamplitude}%
        {.3\pgfdecorationsegmentamplitude}%
      }%
      {\pgfqpoint{0pt}{0pt}}%
    }%
    \tikzset{%
      taper width=.5\pgflinewidth,%
      taper%
    }%%
    \pgfsyssoftpath@getcurrentpath\cal@tmp@path%
    \CopperplatePath{\cal@tmp@path}%
  }%
  \state{final}{}%
}%
\pgfdeclaredecoration{calligraphic straight parenthesis}{brace}
{
  \state{brace}[width=+\pgfdecoratedremainingdistance,next state=final]%
  {%
    \pgfsyssoftpath@setcurrentpath{\pgfutil@empty}%
    \pgfpathmoveto{\pgfpointorigin}%
    \pgfpathcurveto%
    {%
      \pgfqpoint%
      {.76604\pgfdecorationsegmentamplitude}%
      {.64279\pgfdecorationsegmentamplitude}%
    }%
    {%
      \pgfqpoint%
      {2.3333\pgfdecorationsegmentamplitude}%
      {\pgfdecorationsegmentamplitude}%
    }%
    {%
      \pgfqpoint%
      {3.3333\pgfdecorationsegmentamplitude}%
      {\pgfdecorationsegmentamplitude}%
    }%
    {%
      \pgftransformxshift{+\pgfdecoratedremainingdistance}%
      \pgfpathlineto%
      {%
        \pgfqpoint%
        {-3.3333\pgfdecorationsegmentamplitude}%
        {\pgfdecorationsegmentamplitude}%
      }%
      \pgfpathcurveto%
      {%
        \pgfqpoint%
        {-2.3333\pgfdecorationsegmentamplitude}%
        {\pgfdecorationsegmentamplitude}%
      }%
      {%
        \pgfqpoint%
        {-.76604\pgfdecorationsegmentamplitude}%
        {.64279\pgfdecorationsegmentamplitude}%
      }%
      {\pgfqpoint{0pt}{0pt}}%
    }%
    \tikzset{%
      taper width=.5\pgflinewidth,%
      taper%
    }%
    \pgfsyssoftpath@getcurrentpath\cal@tmp@path%
    \CopperplatePath{\cal@tmp@path}%
  }%
  \state{final}{}%
}
\pgfdeclaredecoration{calligraphic curved parenthesis}{brace}
{
  \state{brace}[width=+\pgfdecoratedremainingdistance,next state=final]%
  {%
    \pgfsyssoftpath@setcurrentpath{\pgfutil@empty}%
    \pgfpathmoveto{\pgfpointorigin}%
    \pgf@xa=\pgfdecoratedremainingdistance\relax%
    \advance\pgf@xa by -1.5890\pgfdecorationsegmentamplitude\relax%
    \edef\cgrphy@xa{\the\pgf@xa}%
    \pgfpathcurveto%
    {%
      \pgfqpoint%
      {1.5890\pgfdecorationsegmentamplitude}%
      {1.3333\pgfdecorationsegmentamplitude}%
    }%
    {\pgfqpoint{\cgrphy@xa}{1.3333\pgfdecorationsegmentamplitude}}%
    {\pgfqpoint{\pgfdecoratedremainingdistance}{0pt}}%
    \tikzset{%
      taper width=.5\pgflinewidth,%
      taper%
    }%
    \pgfsyssoftpath@getcurrentpath\cal@tmp@path%
    \CopperplatePath{\cal@tmp@path}%
  }%
  \state{final}{}%
}
\fi
%% 
%% Copyright (C) 2011-2021 by Andrew Stacey <loopspace@mathforge.org>
%% 
%% This work 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 work is "maintained" (as per LPPL maintenance status) by
%% Andrew Stacey.
%% 
%% This work consists of the files  spath3_code.dtx
%%                                  calligraphy_doc.tex
%%                                  knots_doc.tex
%%                                  spath3.tex
%% and the derived files            spath3.ins,
%%                                  spath3_code.pdf,
%%                                  spath3.sty,
%%                                  tikzlibrarycalligraphy.code.tex
%%                                  tikzlibraryknots.code.tex
%%                                  tikzlibraryspath3.code.tex
%%                                  calligraphy.pdf
%%                                  knots.pdf
%%                                  spath3.pdf
%%                                  README
%% 
%%
%% End of file `tikzlibrarycalligraphy.code.tex'.
