diff options
author | Karl Berry <karl@freefriends.org> | 2023-04-29 19:48:57 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2023-04-29 19:48:57 +0000 |
commit | a67da228089c0fa6d13ad4d1e7d7310826b2350b (patch) | |
tree | a4b8d2da00ec844500f90593284f3347b20a0178 /Master/texmf-dist/tex/latex/playcards | |
parent | 155a4d93bdea282dfb4d72f2a5d3f54e133e9ac0 (diff) |
playcards (29apr23)
git-svn-id: svn://tug.org/texlive/trunk@66968 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/playcards')
-rw-r--r-- | Master/texmf-dist/tex/latex/playcards/playcards.sty | 177 |
1 files changed, 177 insertions, 0 deletions
diff --git a/Master/texmf-dist/tex/latex/playcards/playcards.sty b/Master/texmf-dist/tex/latex/playcards/playcards.sty new file mode 100644 index 00000000000..aa5218f2418 --- /dev/null +++ b/Master/texmf-dist/tex/latex/playcards/playcards.sty @@ -0,0 +1,177 @@ +% Clément PAGÈS <contact@clementpages.fr> +% +% Version 0.1 +% +% Draws basic playcards with Tikz. Inspired by https://tex.stackexchange.com/questions/47924/creating-playing-cards-using-tikz +% +% Provides cards for a4paper format +% +% Licence Gnu Lesser General Public Licence https://www.gnu.org/licenses/lgpl-3.0.html + + + +\NeedsTeXFormat{LaTeX2e} +\ProvidesPackage{playcards}[2023/04/29, Personal commands] + + +\RequirePackage[scale=0.950]{geometry} + +\RequirePackage{simplekv} +\RequirePackage{anttor} +\RequirePackage{graphicx} +\RequirePackage{tikz} +\usetikzlibrary{patterns} +\usetikzlibrary{shadows} +\usepgflibrary {shadings} +\tikzset{ + x=1mm,y=1mm, + cardcorners/.style={ + rounded corners=4 + }, +} + +\RequirePackage[outline]{contour} + +\pgfmathsetmacro{\cardwidth}{59} +\pgfmathsetmacro{\cardheight}{89} +\pgfmathsetmacro{\cardmargin}{4} +\pgfmathsetmacro{\cardwidthbody}{\cardwidth-\cardmargin} +\pgfmathsetmacro{\cardheightbody}{\cardheight-\cardmargin} +\pgfmathsetmacro{\stripwidth}{10} +\pgfmathsetmacro{\strippadding}{2} + + +\def\shapeCard{(0,0) rectangle (\cardwidth,\cardheight)} +\def\shapeCardBody{(0,0) rectangle (\cardwidthbody,\cardheightbody)} +\def\shapeMargin{(\cardmargin,\cardmargin) rectangle (\cardwidthbody,\cardheightbody)} + + + +\newcommand{\carddebug}{ + \draw [step=1,help lines] (0,0) grid (\cardwidth,\cardheight); +} + +\newcommand{\cardborder}{ + \draw[lightgray,cardcorners] \shapeCard; + \draw[black,cardcorners,line width=1pt] \shapeMargin; +} + +\newcommand{\cardpadding}{ + \draw[white,cardcorners] {(0,0) rectangle (\cardwidth+2,\cardheight+2)}; +} + + +\setKVdefault[RectoKeys]{borders=true, trame=true, corners=true, backgroundImg=true, textColor=black, backgroundColor=red, contentsFontSize=120, circleRay=20} +\setKVdefault[VersoKeys]{backgroundImg=true, trame=true, contentsFontSize=50} + + + +\newcommand{\cardbackgroundverso}[2][]{ + \pgfmathsetmacro{\textsize}{\useKV[VersoKeys]{contentsFontSize}} + \pgfmathsetmacro{\textlineskip}{1.2*\textsize} + \clip[cardcorners] \shapeCard; + \ifboolKV[VersoKeys]{backgroundImg} {% + \begin{scope} % Draw background + \draw[shading=color wheel,opacity=0.6] (0,0) rectangle (\cardwidth,\cardheight); + \end{scope} + }{% + \draw[cardcorners, line width=1pt] \shapeCard;% + }% + \begin{scope}[shift={(0.5*\cardwidth,0.5*\cardheight)}] % White text + \node[rotate=45, color=white] at (0,0) {\contourlength{1pt}\contour{black!}{\fontsize{\textsize}{\textlineskip pt}\selectfont #2}}; + \end{scope} +} + + +\newcommand{\cardcontent}[2][]{ + \pgfmathsetmacro{\textsize}{\useKV[RectoKeys]{contentsFontSize}} + \pgfmathsetmacro{\textlineskip}{1.2*\textsize} + \showKV[RectoKeys]{backgroundImg} + \showKV[RectoKeys]{backgroundColor} + \begin{scope} + \ifboolKV[RectoKeys]{borders} { + \clip[cardcorners] \shapeMargin; + }{ + \clip[cardcorners] \shapeCard; + } + \ifboolKV[RectoKeys]{backgroundImg} { + \shade[xshift=29.5mm, yshift=44.5mm, inner color={\useKV[RectoKeys]{backgroundColor}}, outer color=white] circle (\cardwidth) circle({\useKV[RectoKeys]{circleRay}}); + } + {} + \draw[color=white] (0,0) -- (60,70); + \draw[color=white] (0,20) -- (60,15); + \draw[color=white] (0,24) -- (60,30); + \draw[color=white] (0,37) -- (60,36); + \draw[color=white] (0,40) -- (60,60); + \draw[color=white] (0,47) -- (60,5); + \draw[color=white] (0,55) -- (60,45); + \draw[color=white] (0,70) -- (40,0); + \draw[color=white] (0,76) -- (60,65); + \draw[color=white] (0,80) -- (25,0); + \draw[color=white] (20,80) -- (15,0); + \draw[color=white] (35,90) -- (0,80); + \draw[color=white] (40,90) -- (60,-20); + \draw[color=white] (0,5) -- (60,90); + \draw[xshift=29.5mm, yshift=44.5mm, fill=white, color=white] circle(({\useKV[RectoKeys]{circleRay}}); + \end{scope} + \node[align=center, text width=5 cm] at (0.5*\cardwidth,0.5*\cardheight) {{\color{\useKV[RectoKeys]{textColor}}\fontsize{\textsize}{\textlineskip}\selectfont #2}}; +} + +\newcommand{\cardcorner}[1]{ + \begin{scope}[shift={(13,76)}] + \draw[rotate=30, fill=white, color=white] (0,0) ellipse (8 and 5) node[color=black, rotate=30]{{\color{\useKV[RectoKeys]{textColor}}{\fontsize{36pt}{43pt}\selectfont #1}}}; + \end{scope} + \begin{scope}[shift={(\cardwidth-13,\cardheight-76)}] + \draw[rotate=30, fill=white, color=white] (0,0) ellipse (8 and 5) node[rotate=210, color=black]{{\color{\useKV[RectoKeys]{textColor}}{\fontsize{36pt}{43pt}\selectfont #1}}}; + \end{scope} +} + + +\newcommand{\drawcardrecto}[2][]{ + \begin{tikzpicture} + \cardborder + \cardpadding + \cardcontent{#2} + \ifboolKV[RectoKeys]{corners}{ + \cardcorner{#2} + }{ + } + \end{tikzpicture}% +} + + +\newcommand{\drawcardverso}[2][]{ + \begin{tikzpicture}% + \cardpadding + \cardbackgroundverso{#2} + \end{tikzpicture} +} + + +\newcommand{\drawcardsverso}[2][]{ + \useKVdefault[VersoKeys]% + \setKV[VersoKeys]{#1}% + \ifboolKV[VersoKeys]{trame}{% + \foreach \k in {0,...,2}{% + \foreach \n in {0,...,2}{% + \noindent\drawcardverso{#2}% + }\\% + }% + }{% + \noindent\drawcardverso{#2}% + }% +} + +\newcommand{\drawcardsrecto}[2][] { + \useKVdefault[RectoKeys]% + \setKV[RectoKeys]{#1}% + \ifboolKV[RectoKeys]{trame}{ + \foreach \k in {0,...,2}{% + \foreach \n in {0,...,2}{% + \noindent\drawcardrecto{#2}% + }\\% + }% + }{ + \noindent\drawcardrecto{#2}% + }% +} |