diff options
author | Karl Berry <karl@freefriends.org> | 2012-09-03 22:56:48 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2012-09-03 22:56:48 +0000 |
commit | 49ee169240901a3f97d82ab2e35e37cf237b3961 (patch) | |
tree | 75a8e3f59aebd5cac9c9132f0bdbd606052cde67 /Master/texmf-dist/tex/latex/hobby/pml3array.sty | |
parent | 8028e80de243e75b6cd0bdc9aec5dbed7c6be192 (diff) |
new tikz package hobby (3sep12)
git-svn-id: svn://tug.org/texlive/trunk@27584 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/hobby/pml3array.sty')
-rw-r--r-- | Master/texmf-dist/tex/latex/hobby/pml3array.sty | 286 |
1 files changed, 286 insertions, 0 deletions
diff --git a/Master/texmf-dist/tex/latex/hobby/pml3array.sty b/Master/texmf-dist/tex/latex/hobby/pml3array.sty new file mode 100644 index 00000000000..e704e4c41ab --- /dev/null +++ b/Master/texmf-dist/tex/latex/hobby/pml3array.sty @@ -0,0 +1,286 @@ +%% +%% This is file `pml3array.sty', +%% generated with the docstrip utility. +%% +%% The original source files were: +%% +%% hobby.dtx (with options: `array') +%% ---------------------------------------------------------------- +%% hobby --- a TikZ/PGF library for drawing smooth(ish) curves using +%% Hobby's algorithm (implemented in LaTeX3) +%% E-mail: stacey@math.ntnu.no +%% Released under the LaTeX Project Public License v1.3c or later +%% See http://www.latex-project.org/lppl.txt +%% ---------------------------------------------------------------- +%% +\RequirePackage{expl3} +\ExplSyntaxOn +\tl_new:N \l_array_tmp_tl +\tl_new:N \l_array_show_tl +\int_new:N \l_array_base_int +\int_new:N \l_array_top_int +\int_new:N \l_array_tmp_int +\int_new:N \g_array_base_int +\int_set:Nn \g_array_base_int {0} +\cs_new:Npn \array_adjust_ends:Nn #1#2 { + \prop_get:NnNTF #1 {base} \l_tmpa_tl + { + \int_compare:nNnTF {\l_tmpa_tl} > {#2} + { + \prop_put:Nnx #1 {base} {\int_eval:n {#2}} + } + {} + } + { + \prop_put:Nnx #1 {base} {\int_eval:n {#2}} + } + \prop_get:NnNTF #1 {top} \l_tmpa_tl + { + \int_compare:nNnTF {\l_tmpa_tl} < {#2} + { + \prop_put:Nnx #1 {top} {\int_eval:n {#2}} + } + {} + } + { + \prop_put:Nnx #1 {top} {\int_eval:n {#2}} + } +} +\cs_new:Npn \array_put:Nnn #1#2#3 { + \exp_args:NNx \prop_put:Nnn #1 {\int_eval:n {#2}} {#3} + \array_adjust_ends:Nn #1{#2} +} +\cs_generate_variant:Nn \array_put:Nnn {Nnx} +\cs_new:Npn \array_get:NnN #1#2#3 { + \exp_args:NNx \prop_get:NnN #1 {\int_eval:n {#2}} #3 +} +\cs_new:Npn \array_get:Nn #1#2 { + \exp_args:NNf \prop_get:Nn #1 { \int_eval:n {#2} } +} +\cs_new:Npn \array_get:NnNTF #1#2#3#4#5 { + \exp_args:NNx \prop_get:NnNTF #1 {\int_eval:n {#2}} #3 {#4}{#5} +} +\cs_new_eq:NN \array_if_empty:NTF \prop_if_empty:NTF +\cs_new_eq:NN \array_new:N \prop_new:N +\cs_new_eq:NN \array_clear:N \prop_clear:N +\cs_new:Npn \array_map_function:NN #1#2 +{ + \array_if_empty:NTF #1 {} { + \prop_get:NnNTF #1 {base} \l_array_tmp_tl { + \int_set:Nn \l_array_base_int {\l_array_tmp_tl} + }{ + \int_set:Nn \l_array_base_int {0} + } + \prop_get:NnNTF #1 {top} \l_array_tmp_tl { + \int_set:Nn \l_array_top_int {\l_array_tmp_tl} + }{ + \int_set:Nn \l_array_top_int {0} + } + \prg_stepwise_inline:nnnn {\l_array_base_int} {1} {\l_array_top_int} { + \array_get:NnN #1 {##1} \l_array_tmp_tl + \exp_args:Nno #2 {##1} \l_array_tmp_tl +} +} {} +} +\cs_generate_variant:Nn \array_map_function:NN { Nc } +\cs_generate_variant:Nn \array_map_function:NN { c , cc } +\cs_new:Npn \array_reverse_map_function:NN #1#2 +{ + \array_if_empty:NTF #1 {} { + \prop_get:NnNTF #1 {base} \l_array_tmp_tl { + \int_set:Nn \l_array_base_int {\l_array_tmp_tl} + }{ + \int_set:Nn \l_array_base_int {0} + } + \prop_get:NnNTF #1 {top} \l_array_tmp_tl { + \int_set:Nn \l_array_top_int {\l_array_tmp_tl} + }{ + \int_set:Nn \l_array_top_int {0} + } + \prg_stepwise_inline:nnnn {\l_array_top_int} {-1} {\l_array_base_int} { + \array_get:NnN #1 {##1} \l_array_tmp_tl + \exp_args:Nno #2 {##1} \l_array_tmp_tl +} +} {} +} +\cs_generate_variant:Nn \array_reverse_map_function:NN { Nc } +\cs_generate_variant:Nn \array_reverse_map_function:NN { c , cc } +\cs_new_protected:Npn \array_map_inline:Nn #1#2 + { + \int_gincr:N \g_prg_map_int + \cs_gset:cpn { array_map_inline_ \int_use:N \g_prg_map_int :nn } + ##1##2 {#2} + \exp_args:NNc \array_map_function:NN #1 + { array_map_inline_ \int_use:N \g_prg_map_int :nn } + \prg_break_point:n { \int_gdecr:N \g_prg_map_int } + } +\cs_generate_variant:Nn \array_map_inline:Nn { c } +\cs_new_protected:Npn \array_reverse_map_inline:Nn #1#2 + { + \int_gincr:N \g_prg_map_int + \cs_gset:cpn { array_map_inline_ \int_use:N \g_prg_map_int :nn } + ##1##2 {#2} + \exp_args:NNc \array_reverse_map_function:NN #1 + { array_map_inline_ \int_use:N \g_prg_map_int :nn } + \prg_break_point:n { \int_gdecr:N \g_prg_map_int } + } +\cs_generate_variant:Nn \array_reverse_map_inline:Nn { c } +\msg_new:nnn { array } { show } + { + The~array~\token_to_str:N #1~ + \array_if_empty:NTF #1 + { is~empty } + { contains~the~items~(without~outer~braces): } + } +\cs_new_protected:Npn \array_show:N #1 + { + \tl_clear:N \l_array_show_tl + \array_map_function:NN #1 \array_show_aux:nn + \__msg_show_variable:Nnx + #1 + { array } + { \l_array_show_tl } + } + +\cs_new_protected:Npn \array_show_aux:nn #1#2 +{ + \tl_if_eq:NNTF {#2} {\q_no_value} {} + { + \tl_put_right:No \l_array_show_tl {\__msg_show_item:nn {#1}{#2}} + } +} +\cs_generate_variant:Nn \array_show:N { c } +\cs_new_protected:Npn \array_push:Nn #1#2 +{ + \prop_get:NnNTF #1 {top} \l_array_tmp_tl + { + \int_set:Nn \l_array_tmp_int {\l_array_tmp_tl} + \int_incr:N \l_array_tmp_int + \array_put:Nnn #1 {\l_array_tmp_int} {#2} + } + { + \array_put:Nnn #1 {\g_array_base_int} {#2} + } +} +\cs_generate_variant:Nn \array_push:Nn {Nx} +\cs_new_protected:Npn \array_unshift:Nn #1#2 +{ + \prop_get:NnNTF #1 {base} \l_array_tmp_tl + { + \int_set:Nn \l_array_tmp_int {\l_array_tmp_tl} + \int_decr:N \l_array_tmp_int + \array_put:Nnn #1 {\l_array_tmp_int} {#2} + } + { + \array_put:Nnn #1 {\g_array_base_int} {#2} + } +} +\cs_generate_variant:Nn \array_unshift:Nn {Nx} +\cs_new_protected:Npn \array_pop:NN #1#2 +{ + \prop_get:NnN #1 {top} \l_array_tmp_tl + \array_get:NnN #1 {\l_array_tmp_tl} #2 + \array_del:Nn #1 {\l_array_tmp_tl} +} +\cs_new_protected:Npn \array_shift:NN #1#2 +{ + \prop_get:NnN #1 {base} \l_array_tmp_tl + \array_get:NnN #1 {\l_array_tmp_tl} #2 + \array_del:Nn #1 {\l_array_tmp_tl} +} +\cs_new_protected:Npn \array_top:NN #1#2 +{ + \prop_get:NnN #1 {top} \l_array_tmp_tl + \array_get:NnN #1 {\l_array_tmp_tl} #2 +} +\cs_new_protected:Npn \array_base:NN #1#2 +{ + \prop_get:NnN #1 {base} \l_array_tmp_tl + \array_get:NnN #1 {\l_array_tmp_tl} #2 +} +\cs_new:Npn \array_top:N #1 +{ + \array_get:Nn #1 {\prop_get:Nn #1 {top}} +} +\cs_new:Npn \array_base:N #1 +{ + \array_get:Nn #1 {\prop_get:Nn #1 {base}} +} +\cs_new_protected:Npn \array_del:Nn #1#2 +{ + \exp_args:NNx \prop_del:Nn #1 {\int_eval:n {#2}} + \int_set:Nn \l_array_tmp_int {0} + \array_map_inline:Nn #1 { + \tl_if_eq:NNTF {##2} {\q_no_value} {} + { + \int_incr:N \l_array_tmp_int + } + } + \int_compare:nNnTF {\l_array_tmp_int} = {0} + { + \prop_clear:N #1 + } + { + \prop_get:NnN #1 {top} \l_array_tmp_tl + \int_compare:nNnTF {#2} = {\l_array_tmp_tl} { + \prop_get:NnN #1 {base} \l_array_tmp_tl + \int_set:Nn \l_array_tmp_int {\l_array_tmp_tl} + \array_map_inline:Nn #1 { + \tl_if_eq:NNTF {##2} {\q_no_value} {} + { + \int_compare:nNnTF {\l_array_tmp_int} < {##1} { + \int_set:Nn \l_array_tmp_int {##1} + }{} + } + } + \prop_put:Nnx #1 {top} {\int_use:N \l_array_tmp_int} + }{} + \prop_get:NnN #1 {base} \l_array_tmp_tl + \int_compare:nNnTF {#2} = {\l_array_tmp_tl} { +p \prop_get:NnN #1 {top} \l_array_tmp_tl + \int_set:Nn \l_array_tmp_int {\l_array_tmp_tl} + \array_map_inline:Nn #1 { + \tl_if_eq:NNTF {##2} {\q_no_value} {} + { + \int_compare:nNnTF {\l_array_tmp_int} > {##1} { + \int_set:Nn \l_array_tmp_int {##1} + }{} + } + } + \prop_put:Nnx #1 {base} {\int_use:N \l_array_tmp_int} + }{} + } +} +\cs_new_protected:Npn \array_length:N #1 +{ + \int_eval:n {\prop_get:Nn #1 {top} - \prop_get:Nn #1 {base}} +} +\ExplSyntaxOff +%% +%% Copyright (C) 2012 by Andrew Stacey <stacey@math.ntnu.no> +%% +%% This file may be distributed and/or modified under the conditions +%% of the LaTeX Project Public License, either version 1.3 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. +%% +%% This work is "maintained" (as per LPPL maintenance status) by +%% Andrew Stacey. +%% +%% This work consists of the files hobby.dtx +%% hobby_doc.tex +%% and the derived files hobby.code.tex +%% pgflibraryhobby.code.tex +%% tikzlibraryhobby.code.tex +%% hobby.ins +%% hobby.pdf +%% hobby_doc.pdf +%% README.txt +%% +%% +%% End of file `pml3array.sty'. |