diff options
author | Karl Berry <karl@freefriends.org> | 2021-01-16 22:27:10 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2021-01-16 22:27:10 +0000 |
commit | 1eeae05f64972a7535b5ea7d86a5a7e3aa8d104d (patch) | |
tree | 1ad09b43f2343353e7a902d8ff5e9cf380a48b45 /Master/texmf-dist/tex/latex/pxpic | |
parent | 4fbb9d78d05c747057de908c88aa4d42379fc24e (diff) |
pxpic (16jan21)
git-svn-id: svn://tug.org/texlive/trunk@57445 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/pxpic')
-rw-r--r-- | Master/texmf-dist/tex/latex/pxpic/pxpic.sty | 106 |
1 files changed, 91 insertions, 15 deletions
diff --git a/Master/texmf-dist/tex/latex/pxpic/pxpic.sty b/Master/texmf-dist/tex/latex/pxpic/pxpic.sty index e18ad4a23e9..bfc93276911 100644 --- a/Master/texmf-dist/tex/latex/pxpic/pxpic.sty +++ b/Master/texmf-dist/tex/latex/pxpic/pxpic.sty @@ -29,7 +29,7 @@ %% and the derived files pxpic.pdf %% pxpic.sty %% -\ProvidesPackage{pxpic}[2021-01-13 v1.1 draw pixel pictures] +\ProvidesPackage{pxpic}[2021-01-16 v1.2 draw pixel pictures] \RequirePackage{xcolor} \RequirePackage{expkv} \@ifdefinable\pxpicHT{\newdimen\pxpicHT} @@ -44,18 +44,25 @@ \protected\ekvdef{pxpic}{wd}{\pxpicWD\dimexpr#1\relax} \protected\ekvdef{pxpic}{gap-hack}{\pxpic@kern\dimexpr#1\relax} \protected\ekvdef{pxpic}{skip}{\ekvdefNoVal{pxpic@px}{#1}{\pxskip}} -\protected\ekvdef{pxpic}{colors}{\ekvparse\pxpic@noval\pxpic@setcolor{#1}} +\protected\ekvdef{pxpic}{colors}{\ekvparse\pxpic@err@noval\pxpic@setcolor{#1}} \ekvletkv{pxpic}{colours}{pxpic}{colors} \protected\ekvdef{pxpic}{mode} {% \@ifundefined{pxpic@parse@px@#1}% - {\pxpic@unknown@mode{#1}}% + {\pxpic@err@unknown@mode{#1}}% {% \expandafter\let\expandafter\pxpic@parse@px \csname pxpic@parse@px@#1\endcsname }% } -\newcommand*\pxpic{\hbox\bgroup\pxpic@} +\protected\ekvdef{pxpic}{color-list} + {% + \@ifundefined{pxpic@colorlist@#1}% + {\pxpic@err@unknown@colorlist{#1}} + {\csname pxpic@colorlist@#1\endcsname}% + } +\ekvletkv{pxpic}{colour-list}{pxpic}{color-list} +\@ifdefinable\pxpic{\protected\def\pxpic{\hbox\bgroup\pxpic@}} \newcommand\pxpic@[2][] {% \vbox @@ -63,6 +70,8 @@ \pxpicsetup{#1}% \let\px\pxpic@px \let\pxskip\pxpic@skip + \advance\pxpicHT\pxpic@kern + \advance\pxpicWD\pxpic@kern \baselineskip\pxpicHT \kern\pxpic@kern \pxpic@parse#2\pxpic@end @@ -75,6 +84,7 @@ \begingroup \pxpicHT\dimexpr#1\relax \pxpicWD\pxpicHT + \pxpic@kern\z@ \leavevmode \lower3.2\pxpicHT\pxpic [mode=px,colours={o=[HTML]{9F393D},g=black!75},skip=.] @@ -99,13 +109,46 @@ } \newcommand\pxpicforget[1] {\expandafter\let\csname\ekv@name{pxpic@px}{#1}N\endcsname\pxpic@undef} -\protected\def\pxpicnewmode#1#2% +\protected\long\def\pxpicnewmode#1#2% {\expandafter\newcommand\csname pxpic@parse@px@#1\endcsname[1]{#2}} -\protected\def\pxpicsetmode#1#2% +\protected\long\def\pxpicsetmode#1#2% {\long\expandafter\def\csname pxpic@parse@px@#1\endcsname##1{#2}} +\protected\def\pxpicnewcolorlist#1% + {% + \@ifundefined{pxpic@colorlist@#1} + {\pxpicsetcolorlist{#1}} + {\pxpic@err@defined@colorlist{#1}\@gobble}% + } +\protected\def\pxpicsetcolorlist#1% + {\expandafter\pxpicsetcolorlist@\csname pxpic@colorlist@#1\endcsname} +\protected\long\def\pxpicsetcolorlist@#1#2% + {% + \edef#1{\ekvparse\pxpic@experr@noval\pxpic@setcolor@colorlist{#2}}% + \begingroup\edef#1{\endgroup\protected\def\unexpanded{#1}{#1}}% + #1% + } +\protected\def\pxpicaddcolorlist#1% + {% + \@ifundefined{pxpic@colorlist@#1} + {\pxpic@err@unknown@colorlist{#1}\@gobble} + {\expandafter\pxpicaddcolorlist@\csname pxpic@colorlist@#1\endcsname}% + } +\protected\long\def\pxpicaddcolorlist@#1#2% + {% + \begingroup + \edef\pxpic@tmp + {\ekvparse\pxpic@experr@noval\pxpic@setcolor@colorlist{#2}}% + \edef\pxpic@tmp + {% + \endgroup + \protected\def\unexpanded{#1}{\unexpanded\expandafter{#1}\pxpic@tmp}% + }% + \pxpic@tmp + } \long\def\pxpic@ifend#1\pxpic@end{} \let\pxpic@ifempty\ekv@ifempty \long\def\pxpic@ifbracket#1\pxpic@end[#2]\pxpic@end{\pxpic@ifempty{#2}} +\newcommand*\pxpic@openbrace{\expandafter{\iffalse}\fi} \newcommand\pxpic@parse[1] {% \pxpic@ifend#1\pxpic@done\pxpic@end @@ -129,7 +172,7 @@ \ekvifdefinedNoVal{pxpic@px}{#1} {\csname\ekv@name{pxpic@px}{#1}N\endcsname}% {% - \pxpic@unknown@px{#1}% + \pxpic@err@unknown@px{#1}% \pxskip }% } @@ -138,7 +181,7 @@ {% \pxpic@ifempty{#1} {\pxskip} - {{\color{#1}\px}}% + {{\@declaredcolor{#1}\px}}% } \def\pxpic@tmp#1% {% @@ -146,7 +189,7 @@ {% \pxpic@ifempty{##1} {\pxskip} - {{\color[#1]{##1}\px}}% + {{\@undeclaredcolor[#1]{##1}\px}}% }% } \pxpic@tmp{rgb} @@ -162,7 +205,7 @@ \pxpic@tmp{Gray} \pxpic@tmp{wave} \let\pxpic@tmp\pxpic@undef -\newcommand\pxpic@px{\vrule\@height\pxpicHT\@width\pxpicWD\@depth\z@} +\newcommand\pxpic@px{\vrule height\pxpicHT width\pxpicWD depth\z@} \newcommand\pxpic@skip{\hskip\pxpicWD} \newcommand\pxpic@setcolor[2] {% @@ -171,15 +214,48 @@ {#1}{#2}% } \newcommand\pxpic@setcolor@a[2] - {\ekvdefNoVal{pxpic@px}{#1}{{\color{#2}\px}}} + {% + \expandafter\def\csname\ekv@name{pxpic@px}{#1}N\endcsname + {{\@declaredcolor{#2}\px}}% + } \newcommand\pxpic@setcolor@b[2] - {\ekvdefNoVal{pxpic@px}{#1}{{\color#2\px}}} -\newcommand\pxpic@noval[1] + {% + \expandafter\def\csname\ekv@name{pxpic@px}{#1}N\endcsname + {{\@undeclaredcolor#2\px}}% +} +\newcommand\pxpic@setcolor@colorlist[2] + {% + \unexpanded\iffalse{\fi + \pxpic@ifbracket\pxpic@end#2.\pxpic@end[]\pxpic@end + {\expandafter\expandafter\expandafter\pxpic@openbrace\pxpic@setcolor@a} + {\expandafter\expandafter\expandafter\pxpic@openbrace\pxpic@setcolor@b} + {#1}{#2}% + }% + } +\newcommand\pxpic@err@noval[1] {\PackageError{pxpic}{Missing colour definition for name `\detokenize{#1}'}{}} -\newcommand\pxpic@unknown@px[1] +\newcommand\pxpic@err@unknown@px[1] {\PackageError{pxpic}{Unknown pixel `\detokenize{#1}'. Skipping}{}} -\newcommand\pxpic@unknown@mode[1] +\newcommand\pxpic@err@unknown@mode[1] {\PackageError{pxpic}{Unknown mode `#1'}{}} +\newcommand\pxpic@err@unknown@colorlist[1] + {\PackageError{pxpic}{Unknown colour list `#1'}{}} +\newcommand\pxpic@err@defined@colorlist[1] + {\PackageError{pxpic}{Colour list `#1' already defined}{}} +\def\pxpic@experr#1% + {% + \long\def\pxpic@experr##1% + {% + \expandafter\expandafter\expandafter + \pxpic@ifend + \@firstofone{#1##1}% + \pxpic@end + }% + } +\begingroup\expandafter\endgroup +\expandafter\pxpic@experr\csname pxpic Error:\endcsname +\newcommand\pxpic@experr@noval[1] + {\pxpic@experr{Missing colour definition for `#1'}} %% %% %% End of file `pxpic.sty'. |