samcarter / tikzducks

A latex package to draw cute rubber ducks with TikZ
https://ctan.org/pkg/tikzducks
LaTeX Project Public License v1.3c
170 stars 13 forks source link

Document how to use /fill with a selected duck #28

Closed pacho2 closed 3 years ago

pacho2 commented 4 years ago

Hello,

Thanks a lot for tikzducks package, it is really amazing.

I would like to know about how to properly solve a problem I have seen that happens when multiple ducks are inside the same \begin{tikzpicture} . That is needed to place different ducks in concrete positions like "Scaled duck and The Ugly Duckling" example of documentation.

The problem that I see is that, when I need to use something relying on /fill, like https://github.com/samcarter/tikzducks/blob/master/duckpond/Donkey.tex

that part is attached to the first duck (in this case the tail of the donkey).

For example with this:

\begin{tikzpicture}
\definecolor{fskin}{RGB}{161,140,126} 
\definecolor{fbill}{RGB}{238,212,191} 
\definecolor{fhair}{RGB}{89,72,72}
\duck[graduate=gray!20!black, tassel=red!70!black,speech={Bla},bubblecolour= cyan!20!white,laughing]
\begin{scope}
\duck[xshift=110pt, scale=.6, yshift=80pt,body=fskin,bill=fbill,shorthair=fhair,bunny,inear=fbill] 
\begin{pgfinterruptboundingbox}
    \node[fskin,rotate=45,scale=3] at (1.7,1.55) {\textsf{s}}
        \fill[fhair,rotate=45] (2.4,0.13) ellipse (0.15 and 0.07);  
\end{pgfinterruptboundingbox}
\end{scope}
\end{tikzpicture}

Thanks a lot for your help

samcarter commented 3 years ago

Sorry for not replying earlier, I just found this among the open issues, I must have overlocked it when you posted it.

You can avoid the problem by shifting and scaling the whole scope environment and not just the duck. If you also add transform shape the size of the s will also be scaled down automatically:

\documentclass{standalone}
\usepackage{tikzducks}

\begin{document}

\begin{tikzpicture}
\definecolor{fskin}{RGB}{161,140,126} 
\definecolor{fbill}{RGB}{238,212,191} 
\definecolor{fhair}{RGB}{89,72,72}

\duck[graduate=gray!20!black,tassel=red!70!black,speech={Bla},bubblecolour= cyan!20!white,laughing]

\begin{scope}[xshift=110pt, scale=.6, yshift=80pt, transform shape]
  \duck[body=fskin,bill=fbill,shorthair=fhair,bunny,inear=fbill] 
  \node[overlay,fskin,rotate=45,scale=3] at (1.7,1.55) {\textsf{s}};
  \fill[overlay,fhair,rotate=45] (2.4,0.13) ellipse (0.15 and 0.07);  
\end{scope}

\end{tikzpicture}

\end{document}

document

pacho2 commented 3 years ago

Thanks for the information!