From 7516c04b155b9684ffa936fd2f21957501999a42 Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Tue, 8 Nov 2016 22:38:47 +0000 Subject: tikzpeople (8nov16) git-svn-id: svn://tug.org/texlive/trunk@42471 c570f23f-e606-0410-a88d-b1316a301751 --- .../texmf-dist/tex/latex/tikzpeople/tikzpeople.sty | 678 +++++++++++++++++++++ 1 file changed, 678 insertions(+) create mode 100644 Master/texmf-dist/tex/latex/tikzpeople/tikzpeople.sty (limited to 'Master/texmf-dist/tex/latex/tikzpeople/tikzpeople.sty') diff --git a/Master/texmf-dist/tex/latex/tikzpeople/tikzpeople.sty b/Master/texmf-dist/tex/latex/tikzpeople/tikzpeople.sty new file mode 100644 index 00000000000..15bb6fff098 --- /dev/null +++ b/Master/texmf-dist/tex/latex/tikzpeople/tikzpeople.sty @@ -0,0 +1,678 @@ +%% Copyright 2016 Nils Fleischhacker +%% +%% This work 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 has the LPPL maintenance status `maintained'. +%% +%% The Current Maintainer of this work is Nils Fleischhacker. +%% +%% This work consists of the files tikzpeople.tex, tikzpeople.sty, +%% tikzpeople.shape.alice.sty, tikzpeople.shape.bob.sty, +%% tikzpeople.shape.bride.sty, tikzpeople.shape.builder.sty, +%% tikzpeople.shape.businessman.sty, tikzpeople.shape.charlie.sty, +%% tikzpeople.shape.chef.sty, tikzpeople.shape.conductor.sty, +%% tikzpeople.shape.cowboy.sty, tikzpeople.shape.criminal.sty, +%% tikzpeople.shape.dave.sty, tikzpeople.shape.graduate.sty, +%% tikzpeople.shape.groom.sty, tikzpeople.shape.guard.sty, +%% tikzpeople.shape.jester.sty, tikzpeople.shape.judge.sty, +%% tikzpeople.shape.mexican.sty, tikzpeople.shape.nun.sty, +%% tikzpeople.shape.nurse.sty, tikzpeople.shape.physician.sty, +%% tikzpeople.shape.pilot.sty, tikzpeople.shape.police.sty, +%% tikzpeople.shape.priest.sty, tikzpeople.shape.sailor.sty, +%% tikzpeople.shape.santa.sty and tikzpeople.shape.surgeon.sty +\NeedsTeXFormat{LaTeX2e} +\ProvidesPackage{tikzpeople}[2016/11/03 v0.2 People shaped nodes for Tikz] + +\RequirePackage{tikz} +\RequirePackage{calc} +\RequirePackage{etoolbox} +\makeatletter +\newif\if@tikzpeople@draft\@tikzpeople@draftfalse +\DeclareOption{draft}{ + \@tikzpeople@drafttrue +} +\newif\if@tikzpeople@demo\@tikzpeople@demofalse +\DeclareOption{demo}{ + \@tikzpeople@demotrue +} +\newif\if@tikzpeople@nobeards\@tikzpeople@nobeardsfalse +\DeclareOption{nobeards}{ + \@tikzpeople@nobeardstrue +} +\ProcessOptions\relax +\usepgflibrary{intersections} +\usetikzlibrary{decorations.markings,decorations.pathmorphing,calc,positioning} + +\newif\if@tikzpeople@mirrored +\pgfkeys{/tikz/mirrored/.is if=@tikzpeople@mirrored} +\newif\if@tikzpeople@female +\pgfkeys{/tikz/female/.is if=@tikzpeople@female} +\newif\if@tikzpeople@evil +\pgfkeys{/tikz/evil/.is if=@tikzpeople@evil} +\newif\if@tikzpeople@good +\pgfkeys{/tikz/good/.is if=@tikzpeople@good} +\newif\if@tikzpeople@monitor +\pgfkeys{/tikz/monitor/.is if=@tikzpeople@monitor} + +\newcommand{\tikzpeople@addcolorkey}[1]{ + \expandafter\def\csname tikzpeople@#1\endcsname{#1} + \pgfkeys{/tikz/#1/.code=\expandafter\def\csname tikzpeople@#1\endcsname{##1}} +} + +\tikzpeople@addcolorkey{shirt} +\tikzpeople@addcolorkey{skin} +\tikzpeople@addcolorkey{hair} +\tikzpeople@addcolorkey{pc} + +\pgfdeclareshape{person}{ + \saveddimen{\scalingfactor}{ + \setlength{\pgf@xa}{\pgfshapeminwidth} + \setlength{\pgf@xb}{9.075pt} + \ifdim\pgf@xa<\pgf@xb + \pgfsetshapeminwidth{9.075pt} + \fi + \setlength{\pgf@xa}{\pgfshapeminheight} + \setlength{\pgf@xb}{0.5cm} + \ifdim\pgf@xa<\pgf@xb + \pgfsetshapeminheight{0.5cm} + \fi + \setlength{\pgf@xa}{1pt*\ratio{\pgfshapeminwidth}{9.075pt}} + \setlength{\pgf@xb}{1pt*\ratio{\pgfshapeminheight}{12.1pt}} + \ifdim\pgf@xa<\pgf@xb + \setlength{\pgf@x}{1pt*\ratio{\pgfshapeminheight}{12.1pt}} + \else + \setlength{\pgf@x}{1pt*\ratio{\pgfshapeminwidth}{9.075pt}} + \fi + } + + \saveddimen{\width}{ + \pgf@x=\wd\pgfnodeparttextbox + } + + \saveddimen{\height}{ + \pgf@x=\ht\pgfnodeparttextbox + } + + \saveddimen{\depth}{ + \pgf@x=\dp\pgfnodeparttextbox + } + + \savedanchor{\mouth}{ + \if@tikzpeople@mirrored + \pgfpoint{-2.075}{1.7} + \else + \pgfpoint{2.4}{1.7} + \fi + } + + \anchor{mouth}{ + \pgfpointscale{\scalingfactor}{\mouth} + } + \anchor{north west}{ + \pgfpointscale{\scalingfactor}{\pgfpoint{-4.375}{6.3}} + } + \anchor{north}{ + \pgfpointscale{\scalingfactor}{\pgfpoint{0.1625}{6.3}} + } + \anchor{north east}{ + \pgfpointscale{\scalingfactor}{\pgfpoint{4.7}{6.3}} + } + \anchor{east}{ + \pgfpointscale{\scalingfactor}{\pgfpoint{4.7}{0.25}} + } + \anchor{south east}{ + \pgfpointscale{\scalingfactor}{\pgfpoint{4.7}{-5.8}} + } + \anchor{south}{ + \pgfpointscale{\scalingfactor}{\pgfpoint{0.1625}{-5.8}} + } + \anchor{south west}{ + \pgfpointscale{\scalingfactor}{\pgfpoint{-4.375}{-5.8}} + } + \anchor{west}{ + \pgfpointscale{\scalingfactor}{\pgfpoint{-4.375}{0.25}} + } + \anchor{center}{ + \pgfpointscale{\scalingfactor}{\pgfpoint{0.1625}{0.25}} + } + \anchor{text}{ + \pgfpoint{\scalingfactor*0.1625-0.5*\width}{\scalingfactor*-6.3-\depth-\height} + } + \anchor{base}{ + \pgfpoint{\scalingfactor*0.1625}{\scalingfactor*-6.3-\depth-\height} + } + \anchor{base west}{ + \pgfpoint{\scalingfactor*-4.375}{\scalingfactor*-6.3-\depth-\height} + } + \anchor{base east}{ + \pgfpoint{\scalingfactor*4.7}{\scalingfactor*-6.3-\depth-\height} + } + \anchor{mid}{ + \pgfpoint{\scalingfactor*0.1625}{\scalingfactor*-6.3-\depth-\height+.5ex} + } + \anchor{mid west}{ + \pgfpoint{\scalingfactor*-4.375}{\scalingfactor*-6.3-\depth-\height+.5ex} + } + \anchor{mid east}{ + \pgfpoint{\scalingfactor*4.7}{\scalingfactor*-6.3-\depth-\height+.5ex} + } + + \anchorborder{ + \@tempdima=\pgf@x + \@tempdimb=\pgf@y + \pgftransformshift{\pgfpoint{\scalingfactor*-0.1625}{\scalingfactor*0.4pt}} + \pgfpointborderellipse{\pgfpoint{\@tempdima}{\@tempdimb}}{\pgfpoint{\scalingfactor*5.9pt}{\scalingfactor*6.9pt}} + } + + + \beforebackgroundpath{ + \pgftransformscale{\scalingfactor} + \if@tikzpeople@mirrored + \pgftransformxscale{-1} + \pgftransformxshift{-0.325} + \fi + \pgftransformshift{\pgfpoint{-0.3}{3.3}} + \if@tikzpeople@draft + \tikzpeople@person@draftstyles + \tikzpeople@person@paintshirt + \tikzpeople@person@paintrighthorn + \tikzpeople@person@painthead + \tikzpeople@person@paintgoatee + \tikzpeople@person@paintlefthorn + \tikzpeople@person@painthalo + \if@tikzpeople@monitor + \tikzpeople@person@paintmonitor + \fi + \else + \tikzpeople@person@definecolors + \tikzpeople@person@definestyles + \tikzpeople@person@paintshirt + \tikzpeople@person@paintrighthorn + \tikzpeople@person@painthead + \tikzpeople@person@painthair + \tikzpeople@person@paintlefthorn + \tikzpeople@person@paintgoatee + \tikzpeople@person@painthalo + \if@tikzpeople@monitor + \tikzpeople@person@paintmonitor + \fi + \fi + } +} + +\newcommand{\tikzpeople@person@definestyles}{ + \tikzstyle{shirt}=[color=\tikzpeople@shirt!80,top color=\tikzpeople@shirt!20, bottom color=\tikzpeople@shirt!80,shading angle=45] + \tikzstyle{skin}=[color=\tikzpeople@skin!80,top color=\tikzpeople@skin!40, bottom color=\tikzpeople@skin!80,shading angle=45] + \tikzstyle{hair}=[color=\tikzpeople@hair!80,top color=\tikzpeople@hair!40, bottom color=\tikzpeople@hair!80,shading angle=45]; + \tikzstyle{goatee}=[color=\tikzpeople@hair!80,top color=\tikzpeople@hair!40, bottom color=\tikzpeople@hair!80,shading angle=45]; + \tikzstyle{horns}=[color=red!80,top color=red!40, bottom color=red!80,shading angle=45]; + \tikzstyle{halo}=[color=yellow!80,top color=yellow!40, bottom color=yellow!80,shading angle=45]; +} + +\newcommand{\tikzpeople@person@draftstyles}{ + \tikzstyle{shirt}=[color=black,fill=white]; + \tikzstyle{skin}=[color=black,fill=white]; + \tikzstyle{hair}=[color=black,fill=white]; + \tikzstyle{goatee}=[color=black,fill=white]; + \tikzstyle{horns}=[color=black,fill=white]; + \tikzstyle{halo}=[color=black,fill=white]; +} + +\newcommand{\tikzpeople@person@definecolors}{ + \definecolor{skin}{rgb}{0.84,0.58,0.24} + \definecolor{shirt}{rgb}{0.34,0.56,0.22} + \definecolor{hair}{rgb}{0.45,0.24,0} + \definecolor{pc}{rgb}{0,0,0} +} + +\newcommand{\tikzpeople@person@paintshirt}{ + \draw[shirt] + (-4.0pt,-8.0pt) .. controls (-2pt,-10pt) and ( 3pt,-9pt) .. + ( 5.0pt,-7.0pt) .. controls ( 5pt, 0pt) and (-5pt, 0pt) .. + (-4.0pt,-8.0pt) -- cycle; +} + +\newcommand{\tikzpeople@person@painthead}{ + \draw[skin] (0pt,0pt) circle (3pt); +} + +\newcommand{\tikzpeople@person@painthair}{ + \if@tikzpeople@female + \tikzpeople@person@paintfemalehair + \else + \draw[hair] + (25:3pt) arc (25:210:3pt) -- (-2.6pt,-0.5pt) -- (-1.7pt,-1pt) -- + (-1.7pt,0.8pt) to[out=350,in=210] (25:3pt) -- cycle; + \fi +} + +\newcommand{\tikzpeople@person@painthairstyletwo}{ + \if@tikzpeople@female + \tikzpeople@person@paintfemalehairstyletwo + \else + \draw[hair] + (15:3pt) arc (15:210:3pt) -- ++(0.3pt,0pt) -- ++(0.1pt,0.5pt) + .. controls +(310:.2pt) .. ++(0.2pt,-0.6pt) -- ++(0.4pt,0pt) + .. controls +(90:1pt) .. (-1.7pt,0.4pt) to[out=350,in=210] + (15:3pt) -- cycle; + \fi +} + +\newcommand{\tikzpeople@person@paintfemalehairstyletwo}{ + \draw[hair] + (15:3pt) arc (15:165:3pt) .. controls +(260:1pt) .. (215:4.5pt) -- + ++(4:0.5pt) -- ++(70:0.5pt) -- ++(285:0.4pt) -- ++(0:1.5pt) -- + (-1.6pt,0pt) to [out=350,in=210] (15:3pt) -- cycle; +} + +\newcommand{\tikzpeople@person@paintfemalehairstylethree}{ + \draw[hair] + (15:3pt) arc (15:180:3.3pt) .. controls +(269:3pt) and +(190:1.5pt) + .. (250:3.4pt) .. controls +(118:1.2pt) .. (-1.6pt,0pt) to [out=350,in=210] + (15:3pt)-- cycle; +} + +\newcommand{\tikzpeople@person@paintgoatee}{ +\if@tikzpeople@nobeards +\else + \if@tikzpeople@evil + { + \pgftransformrotate{5} + \draw[goatee] (285:1.75pt) + -- ++(0:1pt) arc[start angle=90, end angle=0, x radius=.55pt, y radius=.5pt] + -- ++(270:.5pt) arc[start angle=0, end angle=-90, x radius=.55pt, y radius=.5pt] + -- ++(180:1pt) arc[start angle=-90, end angle=-180, x radius=.55pt, y radius=.5pt] + -- ++(90:.5pt) arc[start angle=180, end angle=90, x radius=.55pt, y radius=.5pt] + (285:1.75pt) ++(.1875pt,-.3pt) + arc[start angle=90,end angle=270,x radius=.45pt, y radius=.3pt] + -- ++(0:.6pt) arc[start angle=-90,end angle=90,x radius=.45pt, y radius=.3pt] + -- ++(180:.6pt); + } + \fi +\fi +} + +\newcommand{\tikzpeople@person@paintlefthorn}{ + \if@tikzpeople@evil + \draw[horns] (140:2.5pt) arc (-90:-170:2pt) arc (0:180:0.04pt) arc (190:240:4pt) to[out=70,in=290] (140:2.5pt) -- cycle; + \fi +} + +\newcommand{\tikzpeople@person@paintrighthorn}{ + \if@tikzpeople@evil + \draw[horns] (40:2.5pt) arc (-90:-10:2pt) arc (180:0:0.04pt) arc (-10:-60:4pt) to[out=110,in=250] (40:2.5pt) -- cycle; + \fi +} + +\newcommand{\tikzpeople@person@painthalo}{ + \if@tikzpeople@good + \draw[fill,halo,even odd rule] + (0.1pt,4.5pt) ellipse (2.8pt and 0.8pt) ++(0pt,.1pt) ellipse (2pt and 0.5pt); + \fi +} + +\newcommand{\tikzpeople@person@paintfemalehair}{ + \draw[hair] + (15:3pt) arc (15:180:3pt) .. controls +(273:2pt) and +(190:2pt) .. (260:3.3pt) .. controls +(140:1pt) .. + (-1.6pt,0pt) to [out=350,in=210] + (15:3pt) -- cycle; +} + +\newcommand{\tikzpeople@person@paintmonitor}{ + \if@tikzpeople@draft + \path[draw=black,fill=white] (2.3pt,-2.3pt) -- ++(14:7.3pt) -- ++(340:.27pt) coordinate (tmp) -- ++(264:6.2pt) -- ++(195.5:7.35pt) coordinate (tmp2) -- ++(135:.3pt) --cycle; + \path[draw=black] (2.3pt,-2.3pt) ++(330:.28pt) coordinate (tmp3) (tmp2) -- (tmp3) -- (tmp); + \path[draw=black] (3pt,-3pt) -- ++(14.5:6.4pt) -- ++(264:5.3pt) -- ++(195.5:6.35pt) coordinate (tmp) --cycle; + \path[draw=black,line width=.15*\scalingfactor,cap=butt] (tmp) -- (3pt,-3pt) -- ++(14.5:6.4pt); + \path[draw=black,fill=white] (6.1pt,-4.8pt) ++(190:.6pt) ++(280:4pt) ++(-1.5pt,.2pt) coordinate (tmp) -- ++(325:1.6pt) -- ++(15:3.7pt) -- ++(145:1.6pt) --cycle; + \path[draw=black] (tmp) -- ++(0,-.2pt) -- ++(325:1.6pt) -- ++(15:3.7pt) -- ++(0,.2pt); + \path (6.1pt,-4.8pt) ++(17:.8pt) coordinate (tmp); + \path[draw=black,fill=white] (tmp) ++(0,.01pt) -- ++(194:1.5pt) -- ++(280:4pt) -- ++(0:.07pt) -- ++(17:.5pt) --cycle; + \path[draw=black,fill=white] (6.1pt,-4.8pt) ++(190:.6pt) -- ++(280:4pt) coordinate (tmp2) -- ++(15:2pt) -- (tmp) --cycle; + \else + \path[top color=\tikzpeople@pc, bottom color=\tikzpeople@pc!60,shading angle=135] (2.3pt,-2.3pt) -- ++(14:7.3pt) -- ++(340:.27pt) coordinate (tmp) -- ++(264:6.2pt) -- ++(195.5:7.35pt) coordinate (tmp2) -- ++(135:.3pt) --cycle; + \path[top color=\tikzpeople@pc!60, bottom color=\tikzpeople@pc!50,shading angle=135] (2.3pt,-2.3pt) ++(330:.28pt) -- (tmp) -- ++(264:6.2pt) -- (tmp2) --cycle; + \path[top color=\tikzpeople@pc!40, bottom color=\tikzpeople@pc!30,shading angle=45] (3pt,-3pt) -- ++(14.5:6.4pt) -- ++(264:5.3pt) -- ++(195.5:6.35pt) coordinate (tmp) --cycle; + \path[draw,color=black!20,line width=.15*\scalingfactor,cap=butt] (tmp) -- (3pt,-3pt) -- ++(14.5:6.4pt); + \begin{scope} + \pgftransformshift{\pgfpoint{6pt}{-4.7pt}} + \pgftransformxslant{0.15} + \path[top color=\tikzpeople@pc, bottom color=\tikzpeople@pc!60,shading angle=90] (0,0) ellipse (1.3pt and 2pt); + \path[top color=\tikzpeople@pc!55, bottom color=\tikzpeople@pc!50,shading angle=135] (.1pt,-.1pt) ellipse (1.3pt and 2pt); + \end{scope} + \path[top color=\tikzpeople@pc!75, bottom color=\tikzpeople@pc!70,shading angle=135] (6.1pt,-4.8pt) ++(160:.9pt) -- ++(15:2pt) -- ++(265:1pt) -- ++(195:2pt) --cycle; + \path (6.1pt,-4.8pt) ++(17:.8pt) coordinate (tmp); + \path[top color=\tikzpeople@pc, bottom color=\tikzpeople@pc!40,shading angle=90] (6.1pt,-4.8pt) ++(190:.6pt) ++(280:4pt) ++(-1.5pt,.2pt) -- ++(0,-.2pt) -- ++(325:1.6pt) -- ++(15:3.7pt) -- ++(0,.2pt) -- cycle; + \path[top color=\tikzpeople@pc!60, bottom color=\tikzpeople@pc!45,shading angle=90] (6.1pt,-4.8pt) ++(190:.6pt) ++(280:4pt) ++(-1.5pt,.2pt) -- ++(325:1.6pt) -- ++(15:3.7pt) -- ++(145:1.6pt) --cycle; + \path[top color=\tikzpeople@pc, bottom color=\tikzpeople@pc!90,shading angle=80] (6.1pt,-4.8pt) ++(190:.6pt) ++(280:4pt) ++(-.6pt,.2pt) -- ++(325:.8pt) -- ++(15:2.5pt) -- ++(145:.8pt) --cycle; + \path[top color=\tikzpeople@pc!70, bottom color=\tikzpeople@pc] (tmp) ++(0,.01pt) -- ++(194:1.5pt) -- ++(280:4pt) -- ++(0:.07pt) -- ++(17:.5pt) --cycle; + \path[top color=\tikzpeople@pc!60, bottom color=\tikzpeople@pc!45,shading angle=90] (6.1pt,-4.8pt) ++(190:.6pt) -- ++(280:4pt) coordinate (tmp2) -- ++(15:2pt) -- (tmp) --cycle; + \fi +} + + +\newcommand{\tikzpeople@declareshape}[1]{ + \if@tikzpeople@draft + \pgfdeclareshape{#1}{ + \inheritsavedanchors[from={person}] + \inheritanchor[from={person}]{north west} + \inheritanchor[from={person}]{north} + \inheritanchor[from={person}]{north east} + \inheritanchor[from={person}]{east} + \inheritanchor[from={person}]{south east} + \inheritanchor[from={person}]{south} + \inheritanchor[from={person}]{south west} + \inheritanchor[from={person}]{west} + \inheritanchor[from={person}]{center} + \inheritanchor[from={person}]{text} + \inheritanchor[from={person}]{base} + \inheritanchor[from={person}]{base west} + \inheritanchor[from={person}]{base east} + \inheritanchor[from={person}]{mid} + \inheritanchor[from={person}]{mid west} + \inheritanchor[from={person}]{mid east} + \inheritanchor[from={person}]{mouth} + \inheritanchorborder[from={person}] + + \beforebackgroundpath{ + \pgftransformscale{\scalingfactor} + \if@tikzpeople@mirrored + \pgftransformxscale{-1} + \pgftransformxshift{-0.325} + \fi + \pgftransformshift{\pgfpoint{-0.3}{3.3}} + \tikzpeople@person@draftstyles + \tikzpeople@person@paintshirt + \tikzpeople@person@paintrighthorn + \tikzpeople@person@painthead + \tikzpeople@person@paintgoatee + \tikzpeople@person@paintlefthorn + \tikzpeople@person@painthalo + \if@tikzpeople@monitor + \tikzpeople@person@paintmonitor + \fi + } + } + \else + \input{tikzpeople.shape.#1.sty} + \pgfdeclareshape{#1}{ + \inheritsavedanchors[from={person}] + \inheritanchor[from={person}]{north west} + \inheritanchor[from={person}]{north} + \inheritanchor[from={person}]{north east} + \inheritanchor[from={person}]{east} + \inheritanchor[from={person}]{south east} + \inheritanchor[from={person}]{south} + \inheritanchor[from={person}]{south west} + \inheritanchor[from={person}]{west} + \inheritanchor[from={person}]{center} + \inheritanchor[from={person}]{text} + \inheritanchor[from={person}]{base} + \inheritanchor[from={person}]{base west} + \inheritanchor[from={person}]{base east} + \inheritanchor[from={person}]{mid} + \inheritanchor[from={person}]{mid west} + \inheritanchor[from={person}]{mid east} + \inheritanchor[from={person}]{mouth} + \inheritanchorborder[from={person}] + + \beforebackgroundpath{ + \pgftransformscale{\scalingfactor} + \if@tikzpeople@mirrored + \pgftransformxscale{-1} + \pgftransformxshift{-0.325} + \fi + \pgftransformshift{\pgfpoint{-0.3}{3.3}} + \tikzpeople@person@definecolors + \csname tikzpeople@#1@definecolors\endcsname + \csname tikzpeople@#1@definestyles\endcsname + \begin{scope} + \csname tikzpeople@#1@paint\endcsname + \end{scope} + \if@tikzpeople@monitor + \tikzpeople@person@paintmonitor + \fi + } + } + \fi + \if@tikzpeople@demo + \ifdef{\tikzpeople@shapelist}{ + \appto\tikzpeople@shapelist{,#1} + }{ + \def\tikzpeople@shapelist{#1} + } + \stepcounter{tikzpeople@totalshapes} + \fi +} + +\newif\ifalltikzpeople@star +\if@tikzpeople@demo + \RequirePackage{capt-of} + \RequirePackage{xifthen} + \newcounter{tikzpeople@shaperow} + \newcounter{tikzpeople@shapecolumn} + \newcounter{tikzpeople@shapenum} + \newcounter{tikzpeople@totalshapes} + \newlength{\tikzpeople@figwidth} + \newlength{\tikzpeople@captionht} + + \newcommand{\tikzpeople@horizontalseparation}[1]{ + \draw ($#1*(-1,1.25) + {2.5*#1}*(0,-\value{tikzpeople@shaperow})$)--+(${2*#1}*(\value{tikzpeople@shapecolumn},0)$); + } + + \newcommand{\tikzpeople@verticalseparation}[1]{ + \draw ($#1*(-1,1.25) + {2*#1}*(\value{tikzpeople@shapecolumn},0) + {2.5*#1}*(0,-\value{tikzpeople@shaperow})$)--+($2.5*(0,-#1)$); + } + + \newcommand{\alltikzpeople}{% + \@ifstar{\alltikzpeople@startrue\alltikzpeople@i*}{\alltikzpeople@starfalse\alltikzpeople@i*}% + } + + \def\alltikzpeople@i*#1#2{% + \setlength{\tikzpeople@figwidth}{#1cm} + \edef\tikzpeople@foreachshape{\noexpand\foreach \noexpand\tikzpeople@shape in {\tikzpeople@shapelist}} + \edef\tikzpeople@numcols{\the\numexpr(\textwidth-(\tikzpeople@figwidth))/(2*\tikzpeople@figwidth)\relax} + \addtocounter{figure}{10} + \settototalheight{\tikzpeople@captionht}{% + \vbox{\captionof{figure}{All available characters with \texttt{minimum width=#1cm} and no additional options.}} + }% + \addtocounter{figure}{-11} + \edef\tikzpeople@numrows{\the\numexpr(2*(\textheight-\tikzpeople@captionht)-(5*\tikzpeople@figwidth/2))/(5*\tikzpeople@figwidth)\relax} + \edef\tikzpeople@numshapes{\the\numexpr\tikzpeople@numcols*\tikzpeople@numrows\relax} + \edef\tikzpeople@numfigs{\the\numexpr\value{tikzpeople@totalshapes}/\tikzpeople@numshapes\relax} + \ifthenelse{\numexpr\tikzpeople@numfigs*\tikzpeople@numshapes\relax<\value{tikzpeople@totalshapes}}{ + \edef\tikzpeople@numfigs{\the\numexpr\tikzpeople@numfigs+1\relax} + }{} + \foreach \tikzpeople@fignum in {1,...,\tikzpeople@numfigs}{ + \begin{figure}[Htp] + \centering + \setcounter{tikzpeople@shapecolumn}{0} + \setcounter{tikzpeople@shaperow}{0} + \setcounter{tikzpeople@shapenum}{0} + \begin{tikzpicture} + \tikzpeople@foreachshape{ + \stepcounter{tikzpeople@shapenum} + \ifthenelse{\value{tikzpeople@shapenum} > \numexpr(\tikzpeople@fignum-1)*\tikzpeople@numshapes\relax}{ + \ifthenelse{\value{tikzpeople@shapenum} < \numexpr\tikzpeople@fignum*\tikzpeople@numshapes+1\relax}{ + \coordinate (\tikzpeople@shape) at (${2*#1}*(\value{tikzpeople@shapecolumn},0) + {2.5*#1}*(0,-\value{tikzpeople@shaperow})$); + \node[minimum width=#1cm,\tikzpeople@shape,#2] at (\tikzpeople@shape) {\texttt{\ifalltikzpeople@star\else\tikzpeople@shape\fi}}; + \tikzpeople@verticalseparation{#1} + \stepcounter{tikzpeople@shapecolumn} + \ifthenelse{\value{tikzpeople@shapecolumn}=\tikzpeople@numcols}{ + \tikzpeople@verticalseparation{#1} + \ifthenelse{\value{tikzpeople@shaperow}=0}{\tikzpeople@horizontalseparation{#1}}{} + \stepcounter{tikzpeople@shaperow} + \tikzpeople@horizontalseparation{#1} + \setcounter{tikzpeople@shapecolumn}{0} + }{} + }{} + }{} + } + \ifthenelse{\value{tikzpeople@shapecolumn}=0}{}{ + \tikzpeople@verticalseparation{#1} + \ifthenelse{\value{tikzpeople@shaperow}=0}{\tikzpeople@horizontalseparation{#1}}{} + \stepcounter{tikzpeople@shaperow} + \tikzpeople@horizontalseparation{#1} + } + \end{tikzpicture} + \caption{\tikzpeople@captiontext{#1}{#2}} + \label{fig:tikzpeoplefigure\tikzpeople@fignum} + \end{figure} + } + } + + \newcommand{\tikzpeople@captiontext}[2]{ + \ifstrempty{#2}{ + All available characters with \texttt{minimum width=#1cm} and no additional options. % + }{% + All available characters with \texttt{minimum width=#1cm} and \texttt{#2} options. % + }% + \ifnum\tikzpeople@numfigs>1% + (Part \tikzpeople@fignum~of \tikzpeople@numfigs) + \fi + } + + \newcommand{\tikzpeoplecolors}[1]{ + \begin{minipage}{.95\textwidth} + \begin{center} + \centering + \expandafter\let\expandafter\tikzpeople@peoplecolors\csname tikzpeople@#1@colors\endcsname + \begin{tikzpicture} + \node[minimum width=2.5cm,#1] {}; + \foreach \tikzpeople@name/\tikzpeople@angle/\tikzpeople@coords in \tikzpeople@peoplecolors{ + \node (label) at (\tikzpeople@angle:2.5) {\tikzpeople@name}; + \foreach \x/\y in \tikzpeople@coords{ + \draw (label) edge (\x,\y); + } + } + \end{tikzpicture} + \captionof{figure}{The available color-keys for \texttt{#1} tikzpeople.} + \end{center} + \end{minipage} + } +\fi + +\tikzpeople@declareshape{alice} +\tikzpeople@declareshape{bob} +\tikzpeople@declareshape{bride} +\tikzpeople@declareshape{builder} +\tikzpeople@declareshape{businessman} +\tikzpeople@declareshape{charlie} +\tikzpeople@declareshape{chef} +\tikzpeople@declareshape{conductor} +\tikzpeople@declareshape{cowboy} +\tikzpeople@declareshape{criminal} +\tikzpeople@declareshape{dave} +\tikzpeople@declareshape{graduate} +\tikzpeople@declareshape{groom} +\tikzpeople@declareshape{guard} +\tikzpeople@declareshape{jester} +\tikzpeople@declareshape{judge} +\tikzpeople@declareshape{mexican} +\tikzpeople@declareshape{nun} +\tikzpeople@declareshape{nurse} +\tikzpeople@declareshape{physician} +\tikzpeople@declareshape{pilot} +\tikzpeople@declareshape{police} +\tikzpeople@declareshape{priest} +\tikzpeople@declareshape{sailor} +\tikzpeople@declareshape{santa} +\tikzpeople@declareshape{surgeon} + +\let\pgfmath@function@veclen\relax +\pgfmathdeclarefunction{veclen}{2}{% + \begingroup% + \pgfmath@x#1pt\relax% + \pgfmath@y#2pt\relax% + \ifdim\pgfmath@x<0pt\relax% + \pgfmath@x-\pgfmath@x% + \fi% + \ifdim\pgfmath@y<0pt\relax% + \pgfmath@y-\pgfmath@y% + \fi% + \ifdim\pgfmath@x=0pt\relax% + \pgfmath@x\pgfmath@y% + \else% + \ifdim\pgfmath@y=0pt\relax% + \else% + \ifdim\pgfmath@x>\pgfmath@y% + \pgfmath@xa\pgfmath@x% + \pgfmath@x\pgfmath@y% + \pgfmath@y\pgfmath@xa% + \fi% + % We use a scaling factor to reduce errors. + % First, see if we should scale down + \let\pgfmath@tmp@scale=\divide + \let\pgfmath@tmp@restore=\multipy + \ifdim\pgfmath@y>10000pt\relax% + \c@pgfmath@counta1500\relax% + \else% + \ifdim\pgfmath@y>1000pt\relax% + \c@pgfmath@counta150\relax% + \else% + \ifdim\pgfmath@y>100pt\relax% + \c@pgfmath@counta50\relax% + \else% + % Not scaling down, should we scale up? + \let\pgfmath@tmp@scale=\multiply + \let\pgfmath@tmp@restore=\divide + \ifdim\pgfmath@y<0.00001pt\relax% + \c@pgfmath@counta1500\relax% + \else% + \ifdim\pgfmath@y<0.0001pt\relax% + \c@pgfmath@counta150\relax% + \else% + \ifdim\pgfmath@y<0.001pt\relax% + \c@pgfmath@counta50\relax% + \else + \c@pgfmath@counta1\relax% + \fi% + \fi% + \fi% + \fi% + \fi% + \fi% + \pgfmath@tmp@scale\pgfmath@x\c@pgfmath@counta\relax% + \pgfmath@tmp@scale\pgfmath@y\c@pgfmath@counta\relax% + \pgfmathreciprocal@{\pgfmath@tonumber{\pgfmath@y}}% + \pgfmath@x\pgfmathresult\pgfmath@x% + \pgfmath@xa\pgfmath@tonumber{\pgfmath@x}\pgfmath@x% + \edef\pgfmath@temp{\pgfmath@tonumber{\pgfmath@xa}}% + % + % Use A+x^2*(B+x^2*(C+x^2*(D+E*x^2))) + % where + % A = +1.000012594 + % B = +0.4993615349 + % C = -0.1195159052 + % D = +0.04453994279 + % E = -0.01019210944 + % + \pgfmath@x-0.01019210944\pgfmath@xa% + \advance\pgfmath@x0.04453994279pt\relax% + \pgfmath@x\pgfmath@temp\pgfmath@x% + \advance\pgfmath@x-0.1195159052pt\relax% + \pgfmath@x\pgfmath@temp\pgfmath@x% + \advance\pgfmath@x0.4993615349pt\relax% + \pgfmath@x\pgfmath@temp\pgfmath@x% + \advance\pgfmath@x1.000012594pt\relax% + \ifdim\pgfmath@y<0pt\relax% + \pgfmath@y-\pgfmath@y% + \fi% + \pgfmath@x\pgfmath@tonumber{\pgfmath@y}\pgfmath@x% + % Invert the scaling factor. + \pgfmath@tmp@restore\pgfmath@x\c@pgfmath@counta\relax% + \fi% + \fi% + \pgfmath@returnone\pgfmath@x% + \endgroup% +} + +\makeatother -- cgit v1.2.3