Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
* dev:
  documentation for the tikz library
  Fixed problem with key values "leaking" out
  Backed out  `transform shape` for the moment and opened #20 instead
  moved super duck definition from tikzlibrary to example
  copied stuff from global gitignore over
  reverted back to own gitignore
  Added aliases with spaces.
  Added a .gitignore
  Added a wrapper around \duck@draw to turn it into a pic, seems to work (but could do with more extensive testing - see duck_library.tex for tests).
  • Loading branch information
samcarter committed Apr 3, 2018
2 parents 5295697 + a0cb685 commit 8b8ba5c
Show file tree
Hide file tree
Showing 5 changed files with 236 additions and 11 deletions.
22 changes: 22 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Specific files #
##################
test.tex

# LaTeX stuff #
###############
*.pdf
*.aux
*.nav
*.out
*.snm
*.toc
*.txss
*.bbl
*.blg
*.fdb_latexmk
*.fls
*.listing
*.dvi
*.ind
*ilg
*idx
116 changes: 116 additions & 0 deletions duckpond/duck_library.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
\documentclass{article}

\usepackage{tikz}
\usetikzlibrary{ducks}

% A test duck with *everything*
\tikzset{
/duck/.cd,
super duck/.style={
duck/.cd,
name=Donald,
% Environment %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
water,
% body parts %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
grumpy,
% hair styles %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
shorthair,
longhair,
crazyhair,
recedinghair,
eyebrow,
beard,
mohican,
mullet,
% clothing %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
tshirt,
jacket,
tie,
cape,
stripes,
% Headgear %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
alien,
hat,
cap,
santa,
unicorn,
magichat,
chef,
witch,
graduate,
beret,
crown,
queencrown,
kingcrown,
peakedcap,
bunny,
tophat,
darthvader,
% Accessories %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
glasses,
sunglasses,
squareglasses,
icecream,
book,
magicwand,
cricket,
rollingpin,
signpost,
lightsaber,
cake,
pizza,
hockey,
baguette,
football,
mask,
necklace,
milkshake,
wine,
prison,
speech,
think,
torch,
easter,
basket,
buttons,
sheep,
horsetail,
crozier,
davidlikespineapplepizza,
}
}

%\usepackage{trace-pgfkeys}

%\pgfkeystracelevel{trace}
%\tikzset{duck/water=blue}
%\pgfkeystracelevel{silent}

\begin{document}

\begin{tikzpicture}
\draw (0,0) pic[duck/super duck] {duck};
\end{tikzpicture}

\begin{tikzpicture}
%\draw (4,0) pic[duck/water=blue] {duck};
\draw (0,0) pic[
duck/water=blue,
duck/book={Animal Farm},
] {duck};
\draw (0,4) pic[
duck/water=blue,
scale=2,
duck/book={Animal Farm},
] {duck};
\end{tikzpicture}

\begin{tikzpicture}
\duck[book={Animal Farm}]
\end{tikzpicture}

\begin{tikzpicture}
\duck[xscale=-1]
\end{tikzpicture}

\end{document}
44 changes: 42 additions & 2 deletions tikzducks-doc.tex
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
\usepackage[english]{babel}
\usepackage[bitstream-charter]{mathdesign}
\usepackage{tikzducks}
\usetikzlibrary{ducks}
\usepackage[most]{tcolorbox}
\usepackage[paper=a4paper,margin=3cm]{geometry}
\usepackage{url}
Expand Down Expand Up @@ -59,7 +60,7 @@
texcsstyle=*\color{duckblue}\bfseries,
keywordstyle=\color{red!60!black}\bfseries,
morekeywords={tikzpicture,scope,patterns,calc,pgfinterruptboundingbox},
moretexcs={duck,path,definecolor,duckpathjacket,duckpathbody,duckpathgrumpybill,duckpathbill,duckpathtshirt,duckpathcape,duckpathshorthair,duckpathlonghair,duckpathcrazyhair,duckpathrecedinghair,duckpathcrown,scalebox,foreach,node,draw,PassOptionsToPackage,usetikzlibrary,selectcolormodel,colorlet,insignia,stripes,color,includegraphics,mcap,setboardfontcolors,setboardfontencoding,WhiteQueenOnWhite,WhiteKingOnWhite,superstripes,shuffleducks,randuck,randomhead,randomaccessories,duckpathmohican,duckpathmullet,duckpathqueencrown,duckpathkingcrown,duckpathdarthvader,duckpathhorsetail},
moretexcs={duck,path,definecolor,duckpathjacket,duckpathbody,duckpathgrumpybill,duckpathbill,duckpathtshirt,duckpathcape,duckpathshorthair,duckpathlonghair,duckpathcrazyhair,duckpathrecedinghair,duckpathcrown,scalebox,foreach,node,draw,PassOptionsToPackage,usetikzlibrary,selectcolormodel,colorlet,insignia,stripes,color,includegraphics,mcap,setboardfontcolors,setboardfontencoding,WhiteQueenOnWhite,WhiteKingOnWhite,superstripes,shuffleducks,randuck,randomhead,randomaccessories,duckpathmohican,duckpathmullet,duckpathqueencrown,duckpathkingcrown,duckpathdarthvader,duckpathhorsetail,tikzset},
delim ={[s][\ttfamily\color{green!50!black}]{$}{$}},
moredelim=[is][\footnotesize\ttfamily\color{orange!70!black}]{|}{|},
index=[1][emph]
Expand Down Expand Up @@ -148,8 +149,10 @@ \subsection{Acknowledgements}
Many other users contributed to this package (in random order):
%
\href{https://tex.stackexchange.com/users/4427/egreg}{Enrico Gregorio} helped to implement the \lstinline|\tikzset{}| interface which makes it much easier to adjust the properties of the ducks to fit the user needs,
%
Andrew Stacey contributed the \TikZ Library ``ducks'',
%
\href{https://tex.stackexchange.com/users/51022/symbol-1}{Symbol 1} solved a few problems with default key values,
\href{https://tex.stackexchange.com/users/51022/symbol-1}{Symbol~1} solved a few problems with default key values,
%
\href{https://tex.stackexchange.com/users/148434/mihikma}{Mihikma} created the duck's beard,
%
Expand Down Expand Up @@ -212,6 +215,43 @@ \section{Usage}
Please note that a negative \lstinline|yscale| will result in awkward rounded corners and text placements for some of the accessories. If an upside-down duck is necessary, e.g. to illustrate the German nursery rhyme \href{https://de.wikipedia.org/wiki/Alle_meine_Entchen}{``Alle meine Entchen''}, please rotate the duck instead.
To make the usage easier for the \TikZ-savvy users, Andrew Stacey contributed a \TikZ library. It can be loaded with \lstinline|\usetikzlibrary{ducks}|. In addition to the normal functionality of the \tikzducks package, the ducks are now also available as \lstinline|pic|. A short example:
\begin{tcolorbox}[title={\TikZ library ``ducks''}]
\begin{lstlisting}[morekeywords={ducks,standalone,tikz,document}]
\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{ducks}
\begin{document}
\begin{tikzpicture}
\draw (0,0) pic[
duck/water=green,
duck/alien,
] {duck};
\draw (4,0) pic[
scale=1.4,
] {duck};
\end{tikzpicture}
\end{document}
\end{lstlisting}
\tcblower
\begin{tikzpicture}
\draw (0,0) pic[
duck/water=green,
duck/alien,
] {duck};
\draw (2,1) pic[
scale=1.4,
] {duck};
\end{tikzpicture}
\end{tcolorbox}
\clearpage
\subsection{Body parts}
The various parts of the duck can also be coloured independently, i.e.\ \lstinline|body|, \lstinline|head| or \lstinline|bill|:
Expand Down
54 changes: 45 additions & 9 deletions tikzducks.sty
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,11 @@
%
%\pgfsetlayers{backgroundlayer,bodylayer,clothinglayer,hairlayer,hatlayer,main}

\newcommand*{\duck}[1][]{\tikzset{%
/duck/.cd,#1}\duck@draw%
\newcommand*{\duck}[1][]{%
\begin{scope}%
\tikzset{/duck/.cd,#1}%
\duck@draw%
\end{scope}%
}

\newif\ifduck@name
Expand Down Expand Up @@ -108,9 +111,13 @@
\newif\ifduck@crozier
\newif\ifduck@davidlikespineapplepizza

\tikzset{
/duck/.cd,
name/.code = \duck@nametrue \def\duck@name{#1},
\tikzset{
%
% Pass unknown keys on to tikz
%
/duck/.search also={/tikz,/pgf},
/duck/.cd,
name/.code= \duck@nametrue \def\duck@name{#1},
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Environment
Expand Down Expand Up @@ -157,9 +164,13 @@
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
shorthair/.code = \duck@shorthairtrue \def\duck@hair{#1},
short hair/.forward to=/duck/shorthair,
longhair/.code = \duck@longhairtrue \def\duck@hair{#1},
long hair/.forward to=/duck/longhair,
crazyhair/.code = \duck@crazyhairtrue \def\duck@hair{#1},
crazy hair/.forward to=/duck/crazyhair,
recedinghair/.code = \duck@recedinghairtrue \def\duck@hair{#1},
receding hair/.forward to=/duck/recedinghair,
eyebrow/.code = \duck@eyebrowtrue \def\duck@eyebrow{#1},
beard/.code = \duck@beardtrue \def\duck@beard{#1},
mohican/.code = \duck@mohicantrue \def\duck@hair{#1},
Expand Down Expand Up @@ -188,16 +199,24 @@
beret/.code = \duck@berettrue \def\duck@beret{#1},
unicorn/.code = \duck@unicorntrue \def\duck@unicorn{#1},
magichat/.code = \duck@magichattrue \def\duck@magichat{#1},
magic hat/.forward to=/duck/magichat,
magicstars/.code = \def\duck@magicstars{#1},
magic stars/.forward to=/duck/magicstars,
witch/.code = \duck@witchtrue \def\duck@witch{#1},
crown/.code = \duck@crowntrue \def\duck@crown{#1},
queencrown/.code = \duck@queencrowntrue \def\duck@queencrown{#1},
queen crown/.forward to=/duck/queencrown,
kingcrown/.code = \duck@kingcrowntrue \def\duck@kingcrown{#1},
king crown/.forward to=/duck/kingcrown,
bunny/.code = \duck@bunnytrue \def\duck@bunny{#1},
inear/.code = \def\duck@inear{#1},
in ear/.forward to=/duck/inear,
peakedcap/.code = \duck@peakedcaptrue \def\duck@peakedcap{#1},
peaked cap/.forward to=/duck/peakedcap,
tophat/.code = \duck@tophattrue \def\duck@tophat{#1},
top hat/.forward to=/duck/tophat,
darthvader/.code = \duck@darthvadertrue \def\duck@darthvader{#1},
darth vader/.forward to=/duck/darthvader,
% setting defaults %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
alien/.default = green,
hat/.default = brown,
Expand Down Expand Up @@ -227,19 +246,31 @@
glasses/.code = \duck@glassestrue \def\duck@glasses{#1},
sunglasses/.code = \duck@sunglassestrue \def\duck@sunglasses{#1},
squareglasses/.code = \duck@squareglassestrue \def\duck@squareglasses{#1},
square glasses/.forward to=/duck/squareglasses,
icecream/.code = \duck@icecreamtrue \def\duck@cone{#1},
ice cream/.forward to=/duck/icecream,
flavoura/.code = \def\duck@flavoura{#1},
flavour a/.forward to=/duck/flavoura,
flavourb/.code = \def\duck@flavourb{#1},
flavour b/.forward to=/duck/flavourb,
flavourc/.code = \def\duck@flavourc{#1},
flavour c/.forward to=/duck/flavourc,
book/.code = \duck@booktrue \def\duck@book{#1},
bookcolour/.code = \def\duck@bookcolour{#1},
book colour/.forward to=/duck/bookcolour,
signpost/.code = \duck@signposttrue \def\duck@signpost{#1},
sign post/.forward to=/duck/signpost,
signcolour/.code = \def\duck@signcolour{#1},
sign colour/.forward to=/duck/signcolour,
signback/.code = \def\duck@signback{#1},
sign back/.forward to=/duck/signback,
magicwand/.code = \duck@magicwandtrue,
magic want/.forward to=/duck/magicwand,
cricket/.code = \duck@crickettrue \def\duck@cricket{#1},
rollingpin/.code = \duck@rollingpintrue \def\duck@rollingpin{#1},
rolling pin/.forward to=/duck/rollingpin,
lightsaber/.code = \duck@lightsabertrue \def\duck@lightsaber{#1},
light saber/.forward to=/duck/lightsaber,
cake/.code = \duck@caketrue \def\duck@cake{#1},
pizza/.code = \duck@pizzatrue,
hockey/.code = \duck@hockeytrue \def\duck@hockey{#1},
Expand All @@ -253,19 +284,24 @@
speech/.code = \duck@speechtrue \def\duck@speech{#1},
think/.code = \duck@thinktrue \def\duck@think{#1},
bubblecolour/.code = \def\duck@bubblecolour{#1},
bubble colour/.forward to=/duck/bubblecolour,
torch/.code = \duck@torchtrue \def\duck@torch{#1},
basket/.code = \duck@baskettrue \def\duck@basket{#1},
easter/.code = \duck@eastertrue
\duck@baskettrue \def\duck@basket{#1},
egga/.code = \def\duck@egga{#1},
egg a/.forward to=/duck/egga,
eggb/.code = \def\duck@eggb{#1},
egg b/.forward to=/duck/eggb,
eggc/.code = \def\duck@eggc{#1},
egg c/.forward to=/duck/eggc,
buttons/.code = \duck@buttonstrue \def\duck@buttons{#1},
sheep/.code = \duck@sheeptrue \def\duck@sheep{#1},
horsetail/.code = \duck@horsetailtrue \def\duck@horsetail{#1},
crozier/.code = \duck@croziertrue \def\duck@crozier{#1},
davidlikespineapplepizza/.code = \duck@davidlikespineapplepizzatrue
\duck@speechtrue \def\duck@speech{\scalebox{\yscalefactor}{\scalebox{0.9}{\tiny ih, che schifo!}}},
\duck@speechtrue \def\duck@speech{\scalebox{\yscalefactor}{\scalebox{0.9}{\tiny ih, che schifo!}}},
david likes pineapple pizza/.forward to=/duck/davidlikespineapplepizza,
% setting defaults %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
glasses/.default = black,
sunglasses/.default= black,
Expand Down Expand Up @@ -303,7 +339,7 @@
}

\def\duck@draw{
\begin{scope}
%\begin{scope}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% minimal bounding box size
Expand Down Expand Up @@ -940,7 +976,7 @@
%
%\draw (current bounding box.north west) rectangle (current bounding box.south east);% For debugging bounding boxes
%
\end{scope}
%\end{scope}
}% from `\def\duck@draw{` at the very beginning

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Expand Down Expand Up @@ -1307,4 +1343,4 @@
%................%%%%%%%%.................%%%...%%%%%%................
%....................%%%%%%%%......%%%%%%%%%%%%%%%....................
%..........................%%%%%%%%%%%%%%%%%..........................
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
11 changes: 11 additions & 0 deletions tikzlibraryducks.code.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
\usepackage{tikzducks}

% This is all that is needed ...
\tikzset{
duck/.pic={%
\duck@draw
},
duck/.search also={,/tikz,/pgf},
}


0 comments on commit 8b8ba5c

Please sign in to comment.