summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/duckuments
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2018-03-15 22:06:50 +0000
committerKarl Berry <karl@freefriends.org>2018-03-15 22:06:50 +0000
commit097c112c554e8f27feadd8c546c4cf0de0489644 (patch)
tree493eea33d1e2c04dd19a7debba8dafcbbb3f8d34 /Master/texmf-dist/tex/latex/duckuments
parent0ee0025f07d63b22f3b16b17f8942c29c30188e9 (diff)
duckuments (15mar18)
git-svn-id: svn://tug.org/texlive/trunk@46973 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/duckuments')
-rw-r--r--Master/texmf-dist/tex/latex/duckuments/duckuments.sty150
-rw-r--r--Master/texmf-dist/tex/latex/duckuments/example-image-duck.pdfbin217654 -> 478693 bytes
2 files changed, 140 insertions, 10 deletions
diff --git a/Master/texmf-dist/tex/latex/duckuments/duckuments.sty b/Master/texmf-dist/tex/latex/duckuments/duckuments.sty
index a18d45c81a1..52ad43ad908 100644
--- a/Master/texmf-dist/tex/latex/duckuments/duckuments.sty
+++ b/Master/texmf-dist/tex/latex/duckuments/duckuments.sty
@@ -31,17 +31,22 @@
%% example-image-duck.tex
%%
\RequirePackage{xparse,letltxmacro,l3keys2e}
-\def\duckuments@version{v0.1}
-\def\duckuments@date{2018/03/13}
+\def\duckuments@version{v0.2}
+\def\duckuments@date{2018/03/14}
\ProvidesExplPackage
{duckuments} {\duckuments@date}
{\duckuments@version} {minimal working duckuments}
-\bool_if:nF { \sys_if_engine_luatex_p: || \sys_if_engine_pdftex_p: }
- { %>>>
+\bool_if:nF
+ {
+ \sys_if_engine_luatex_p:
+ || \sys_if_engine_pdftex_p:
+ || \sys_if_engine_xetex_p:
+ }
+ {%>>>
\msg_new:nnnn { duckuments } { incompatible }
{
- The~duckuments~package~is~currently~only~compatible~with~pdfTeX~and~
- LuaTeX!
+ The~duckuments~package~is~currently~only~compatible~with~pdfTeX,~
+ LuaTeX,~and~XeTeX!
}
{
Sorry~for~that.
@@ -71,13 +76,136 @@
}
}
}%<<<
-\newcommand*\duckuments@randoms{100}
+\newcommand*\duckuments@randoms{128}
\bool_new:N \l_duckuments_immediate_bool
\bool_new:N \l_duckuments_toc_bool
\bool_new:N \l_duckuments_math_inline_bool
\bool_new:N \l_duckuments_math_display_bool
\regex_const:Nn \c_duckuments_regex
{ example-image-duck|example-image-duck.pdf }
+\str_if_eq:VnF \c_sys_jobname_str { example-image-duck }
+{\file_if_exist:nTF { example-image-duck.pdf }
+ {
+ \sys_if_engine_pdftex:T
+ {
+ \pdfximage{example-image-duck.pdf}
+ \int_const:Nn \c_duckuments_example_pages_int
+ { \the\pdflastximagepages }
+ }
+ \sys_if_engine_luatex:T
+ {
+ \saveimageresource{example-image-duck.pdf}
+ \int_const:Nn \c_duckuments_example_pages_int
+ { \lastsavedimageresourcepages }
+ }
+ \sys_if_engine_xetex:TF
+ {
+ \int_set:Nn \l_tmpa_int { \XeTeXpdfpagecount "example-image-duck.pdf" }
+ \int_const:Nn \c_duckuments_example_pages_int { \l_tmpa_int }
+ \int_new:N \g_duckuments_RCiv_i_int
+ \int_new:N \g_duckuments_RCiv_j_int
+ \int_new:N \g_duckuments_RCiv_keylength_int
+ \int_new:N \g_duckuments_tmpa_int
+ \int_const:Nn \c_duckuments_RCiv_Slength_int { 256 }
+ \tl_new:N \l_duckuments_tmpa_tl
+ \tl_new:N \l_duckuments_tmpb_tl
+ \cs_generate_variant:Nn \prop_gput:Nnn { Nxx }
+ \cs_generate_variant:Nn \prop_get:NnN { NxN }
+ \prop_new:N \g_duckuments_RCiv_S_prop
+ \int_step_inline:nnnn { 0 } { 1 } { 255 }
+ {
+ \prop_gput:Nnn \g_duckuments_RCiv_S_prop { #1 } { #1 }
+ }
+ \prop_new:N \g_duckuments_RCiv_key_prop
+ \prop_gput:Nnx \g_duckuments_RCiv_key_prop
+ { 0 } { \int_use:N \c_sys_minute_int }
+ \prop_gput:Nnx \g_duckuments_RCiv_key_prop
+ { 1 } { \c_sys_hour_int }
+ \prop_gput:Nnx \g_duckuments_RCiv_key_prop
+ { 2 } { \c_sys_day_int }
+ \prop_gput:Nnx \g_duckuments_RCiv_key_prop
+ { 3 } { \c_sys_month_int }
+ \prop_gput:Nnx \g_duckuments_RCiv_key_prop
+ { 4 } { \int_eval:n { \int_mod:nn { \c_sys_year_int } { 256 } } }
+ \int_gset:Nn \g_duckuments_RCiv_keylength_int { 5 }
+ \str_map_inline:Nn \c_sys_jobname_str
+ {
+ \prop_gput:Nxx \g_duckuments_RCiv_key_prop
+ { \int_use:N \g_duckuments_RCiv_keylength_int }
+ { \int_from_alph:n { #1 } }
+ \int_gadd:Nn \g_duckuments_RCiv_keylength_int { 1 }
+ }
+ \cs_new:Nn \duckuments_swap_prop_entries:Nnn
+ {
+ \prop_get:NnN #1 { #2 } \l_duckuments_tmpa_tl
+ \prop_get:NnN #1 { #3 } \l_duckuments_tmpb_tl
+ \prop_gput:Nnx #1 { #2 } { \l_duckuments_tmpb_tl }
+ \prop_gput:Nnx #1 { #3 } { \l_duckuments_tmpa_tl }
+ }
+ \cs_generate_variant:Nn \duckuments_swap_prop_entries:Nnn { Nxx }
+ \cs_new:Nn \duckuments_gadd_mod:Nnn
+ {
+ \int_gset:Nn #1 { \int_mod:nn { #1 + #2 } { #3 } }
+ }
+ \cs_generate_variant:Nn \duckuments_gadd_mod:Nnn { Nxn }
+ \cs_new:Nn \duckuments_gadd_mod_Slength:Nn
+ {
+ \duckuments_gadd_mod:Nnn #1
+ { #2 } { \c_duckuments_RCiv_Slength_int }
+ }
+ \int_step_inline:nnnn { 0 } { 1 } { 255 }
+ {
+ \prop_get:NnN \g_duckuments_RCiv_S_prop { #1 } \l_duckuments_tmpa_tl
+ \int_gset:Nn \g_duckuments_tmpa_int
+ {
+ \int_mod:nn
+ { #1 }
+ { \g_duckuments_RCiv_keylength_int }
+ }
+ \prop_get:NxN \g_duckuments_RCiv_key_prop
+ { \int_use:N \g_duckuments_tmpa_int } \l_duckuments_tmpb_tl
+ \duckuments_gadd_mod_Slength:Nn \g_duckuments_RCiv_j_int
+ { \l_duckuments_tmpa_tl + \l_duckuments_tmpb_tl }
+ \duckuments_swap_prop_entries:Nxx \g_duckuments_RCiv_S_prop
+ { #1 } { \int_use:N \g_duckuments_RCiv_j_int }
+ }
+ \int_gzero:N \g_duckuments_RCiv_i_int
+ \int_gzero:N \g_duckuments_RCiv_j_int
+ \cs_new:Nn \duckuments_get_random_page:
+ {
+ \duckuments_gadd_mod_Slength:Nn \g_duckuments_RCiv_i_int { \c_one }
+ \prop_get:NxN \g_duckuments_RCiv_S_prop
+ { \int_use:N \g_duckuments_RCiv_i_int } \l_duckuments_tmpa_tl
+ \duckuments_gadd_mod_Slength:Nn \g_duckuments_RCiv_j_int
+ { \l_duckuments_tmpa_tl }
+ \duckuments_swap_prop_entries:Nxx \g_duckuments_RCiv_S_prop
+ { \int_use:N \g_duckuments_RCiv_i_int }
+ { \int_use:N \g_duckuments_RCiv_j_int }
+ \int_gset:Nn \g_duckuments_tmpa_int { \l_duckuments_tmpa_tl }
+ \duckuments_gadd_mod_Slength:Nn \g_duckuments_tmpa_int
+ { \l_duckuments_tmpb_tl }
+ \prop_get:NxN \g_duckuments_RCiv_S_prop
+ { \int_use:N \g_duckuments_tmpa_int } \l_duckuments_tmpa_tl
+ \int_gset:Nn \g_duckuments_tmpa_int
+ {
+ \int_mod:nn
+ { \l_duckuments_tmpa_tl } { \c_duckuments_example_pages_int }
+ + \c_one
+ }
+ \cs_set:Nx \duckuments_random_page:
+ { \int_use:N \g_duckuments_tmpa_int }
+ }
+ \cs_new:Nn \duckuments_random_page: { 1 }
+ }
+ {
+ \cs_new:Nn \duckuments_get_random_page: {}
+ \cs_new:Nn \duckuments_random_page:
+ { \int_rand:nn { 1 } { \c_duckuments_example_pages_int } }
+ }
+ }}
+ {
+ \int_const:Nn \c_duckuments_example_pages_int { 1 }
+ }
\keys_define:nn { duckuments }
{%>>>
,toc .bool_set:N = \l_duckuments_toc_bool
@@ -170,9 +298,9 @@
{ \end{document} }
\iow_close:N \duckuments_example_file_iow
}%<<<
-\newcommand*\duckumentsDrawRandomDucks
+\newcommand*\duckumentsDrawRandomDucks[1][\duckuments@randoms]
{%>>>
- \foreach\x in {1,2,...,\duckuments@randoms}
+ \foreach\x in {1,2,...,#1}
{\begin{tikzpicture}
\draw[black,fill=gray!50] (0,0) rectangle (6,4);
\draw[gray,thin] (0,0) -- (6,4);
@@ -233,8 +361,10 @@
{
\regex_match:NnTF \c_duckuments_regex { ##3 }
{
+ \duckuments_get_random_page:
\duckuments@includegraphicsBAK##1
- [page=\int_rand:nn{1}{\duckuments@randoms},##2] { ##3 }
+ [page=\duckuments_random_page:,##2]
+ { ##3 }
}
{
\duckuments@includegraphicsBAK##1[##2]{##3}
diff --git a/Master/texmf-dist/tex/latex/duckuments/example-image-duck.pdf b/Master/texmf-dist/tex/latex/duckuments/example-image-duck.pdf
index 8e7e2e2bb1f..d602328399f 100644
--- a/Master/texmf-dist/tex/latex/duckuments/example-image-duck.pdf
+++ b/Master/texmf-dist/tex/latex/duckuments/example-image-duck.pdf
Binary files differ