我们如何画一只鸭子(为了创建一个 tikzducks 包并将其存储在 CTAN 中)?

我们如何画一只鸭子(为了创建一个 tikzducks 包并将其存储在 CTAN 中)?

这个问题导致了一个新的方案的出现:
tikzducks

我们有一个scsnowman包裹,但我们没有ducks包裹,这很难解释,因为鸭子是TeX.SE 上常用(例如,samcarter 不得不\PHdove依靠phaistos这里)。

我不是专家,尽管如此,我想创建一个tikzducks类似的包tikzpeople,但我需要您的帮助才能创建可定制的鸭子!

要求:

  • 我想要一个duck,而不是有点像的东西(不接受具有人体的鸭子)
  • 翅膀是必需的
  • 从鸭子的外观来看,应该可以清楚地看出它是用 LaTeX 创建的,而不是用其他商业工具创建的。

鸭子的可能颜色键:

  • 身体
  • 翅膀
  • 眼睛
  • 喙。

可能的可选附加组件:

  • 帽子
  • 运动工具(例如板球棒)
  • 男/女版本
  • 季节性版本
  • 中文版
  • 烹饪版本(非烹饪版本)
  • 数学家版本。

正如 Ulrike Fisher 的回答所示,tikzpeople包具有喙的特征,但它不允许改变图像的主体,所以我们得到一个有喙的人(相当丑陋)。

Loopspace 指出,目前已经有一个ducks包裹但它不允许改变鸭子的风格(就像人一样tikzpeople),而且它还没有出现在 CTAN 中。

此外,我想要一种类似于这个季节性版本示例的风格:

在此处输入图片描述

去野外!

PS=考虑这个问题,就好像它总是有赏金开放一样!

答案1

不会再有新的鸭子添加到问题中,相反,这个项目将继续成为一个乳胶包。请访问项目存储库https://github.com/samcarter/tikzducks或者看看https://www.ctan.org/pkg/tikzducks如果你想看新的鸭子:)

在此处输入图片描述

\documentclass{article}
\usepackage[svgnames]{xcolor}
\usepackage{tikz}
\usetikzlibrary{decorations.pathmorphing}

\usepackage[paperwidth=38cm,paperheight=42cm,margin=1cm]{geometry}

\usepackage{bbding}

\newcommand{\duck}[1]{%

    \colorlet{duck}{#1}
    \colorlet{eye}{Cornsilk}
    \colorlet{pupil}{black}
    \colorlet{bill}{orange}

    %body
    \path[fill=duck] (51.2815,135.5394) .. controls (26.6859,139.7884) and (-12.5215,184.2616) .. (28.9411,223.8858) .. controls (70.4036,263.5099) and (286.2675,236.9673) .. (181.7701,108.1215) .. controls (93.7517,155.4266) and (123.9624,112.1537) .. (51.2815,135.5394) -- cycle;

    %head
    \path[fill=duck] (90,100) ellipse (1.4cm and 1.75cm);

    % duck's bill
    \path[fill=bill, xshift=-11pt, xscale=1.1] (49.3866,102.7929) .. controls (70.9472,97.0244) and (61.6632,119.6616) .. (95.1826,113) .. controls (20,165) and (36.9082,113.0997) .. (49.3866,102.7929) -- cycle;

    % right eye
    \path[fill=eye, rotate=20, xshift=-4pt, yshift=1pt] (112,58) ellipse (0.25cm and 0.35cm);
    \path[fill=pupil, rotate=20, xshift=-4pt, yshift=1pt] (115,59) ellipse (0.1cm and 0.2cm);

    % left eye
    \path[fill=eye, rotate=20] (78,62) ellipse (0.22cm and 0.32cm);
    \path[fill=pupil, rotate=20] (81,63) ellipse (0.08cm and 0.18cm);

}

\newcommand{\grumpyduck}[1]{%

    \colorlet{duck}{#1}
    \colorlet{eye}{Cornsilk}
    \colorlet{pupil}{black}
    \colorlet{bill}{orange}

    %body
    \path[fill=duck] (51.2815,135.5394) .. controls (26.6859,139.7884) and (-12.5215,184.2616) .. (28.9411,223.8858) .. controls (70.4036,263.5099) and (286.2675,236.9673) .. (181.7701,108.1215) .. controls (93.7517,155.4266) and (123.9624,112.1537) .. (51.2815,135.5394) -- cycle;

    %head
    \path[fill=duck] (90,100) ellipse (1.4cm and 1.75cm);

    % duck's bill
    \path[fill=bill, xshift=-11pt, xscale=1.1] (49.3866,102.7929) .. controls (70.9472,97.0244) and (70.9472,97.0244) .. (85.1826,120) .. controls (20,165) and (36.9082,113.0997) .. (49.3866,102.7929) -- cycle;

    % right eye
    \path[fill=eye, rotate=20, xshift=-4pt, yshift=1pt] (112,58) ellipse (0.25cm and 0.35cm);
    \path[fill=pupil, rotate=20, xshift=-4pt, yshift=1pt] (115,59) ellipse (0.1cm and 0.2cm);

    % left eye
    \path[fill=eye, rotate=20] (78,62) ellipse (0.22cm and 0.32cm);
    \path[fill=pupil, rotate=20] (81,63) ellipse (0.08cm and 0.18cm);

}

\newcommand{\addalien}{%
    \draw[line width=3pt,color=YellowGreen] (110,62) -- (130,20);
    \draw[line width=3pt,color=YellowGreen] (72,58) -- (60,15);
    \path[fill=YellowGreen] (130,20) circle (0.2cm);
    \path[fill=YellowGreen] (60,15) circle (0.2cm);
}

\newcommand{\addhat}[1]{%
    \path[fill=#1] (90,55) ellipse (1.3cm and 0.25cm);
    \path[fill=#1] (90,30) ellipse (0.7cm and 0.2cm);
    \path[fill=#1] (115,30) rectangle (65,55);
}

\newcommand{\addsunglasses}{
    \draw[line width=3pt,color=black] (48,95) arc (190:370:20) ;
    \path[draw=black,line width=3pt] (95,90) -- (130,100);
    \path[fill=black, rotate=20] (111,58) ellipse (0.4cm and 0.4cm);
    \path[fill=black, rotate=20] (80,60) ellipse (0.37cm and 0.37cm);
}

\newcommand{\addglasses}[1]{
    \draw[line width=2pt,color=#1] (62,80) arc (267:297:20) ;
    \path[draw=#1,line width=2pt] (93,88) -- (130,100);
    \path[draw=#1,line width=2pt, rotate=20] (107,58) ellipse (0.35cm and 0.35cm);
    \path[draw=#1,line width=2pt, rotate=20] (78,61) ellipse (0.32cm and 0.32cm);
}

\newcommand{\addicecream}[3]{
    \path[draw=Sienna,fill=Goldenrod,line width=1pt,yshift=50pt,rotate=20,xshift=50pt] 
    (45,60)--(60,120)--(75,60);
    \path[draw=Sienna, fill=Goldenrod, rotate=20,line width=1pt] (144,118) ellipse (0.4cm and 0.25cm);
    \path[fill=#1, rotate=20] (138,116) circle (0.3cm);
    \path[fill=#2, rotate=20] (148,116) circle (0.3cm);
    \path[fill=#3, rotate=20] (142,102) circle (0.3cm);
}

\newcommand{\addunicorn}{
    \path[draw=VioletRed,fill=Pink,line width=1pt,yshift=20pt,rotate=-25,xshift=0pt] 
    (50,60)--(60,20)--(70,60);
}

\newcommand{\addhair}[1]{%
    \path[fill=#1, xshift=-5pt] (151.3277,174.3473) .. controls (157.7099,171.1213) and (164.7938,167.8644) .. (168.7230,161.6896) .. controls (164.8427,161.5316) and (153.5102,155.4255) .. (162.1164,152.9395) .. controls (169.4207,153.1460) and (176.4092,149.5358) .. (179.3920,142.6587) .. controls (185.5577,133.4026) and (172.4051,138.2448) .. (169.0163,134.3455) .. controls (174.7801,132.5948) and (184.6532,131.7138) .. (187.4798,127.5635) .. controls (176.4675,125.1191) and (163.1258,123.3733) .. (156.8817,112.6068) .. controls (152.4387,98.5734) and (153.2098,83.5059) .. (149.6492,69.2411) .. controls (131.4926,-1.1678) and (29.6020,22.0627) .. (47.7294,90.0940) .. controls (49.6639,62.0732) and (72.5401,38.6998) .. (96.3583,54.2220) .. controls (130.5162,76.1752) and (139.7469,117.8581) .. (115.3043,143.8986) .. controls (115.2213,148.9109) and (117.2762,158.3403) .. (124.2981,163.2993) .. controls (131.3200,168.2584) and (141.2814,171.4676) .. (151.3277,174.3473) -- cycle;
}

\newcommand{\addshirt}[1]{%
    \path[fill=#1] (50,135.5394) .. controls (26.6859,139.7884) and (-12.5215,184.2616) .. (28.9411,223.8858) .. controls (70.4036,263.5099) and (286.2675,236.9673) .. (181.7701,108.1215) .. controls (93.7517,155.4266) and (123.9624,112.1537) .. (51.2815,180) -- cycle;
}

\newcommand{\addtie}[1]{
    \draw[line width=10pt,color=#1] (60,150) -- (50,190);
}

\newcommand{\addtshirt}[1]{
    \path[fill=#1] (50,135.5394) .. controls (26.6859,139.7884) and (-12.5215,184.2616) .. (28.9411,223.8858) .. controls (70.4036,263.5099) and (286.2675,236.9673) .. (181.7701,108.1215) .. controls (93.7517,155.4266) and (123.9624,122.1537) .. (59,150) -- cycle;
}

\newcommand{\addshorthair}[1]{
    \path[fill=#1, xshift=-5pt] (145.7190,108.2466) .. controls (151.7052,104.8240) and (153.2448,84.3447) .. (149.6842,70.0799) .. controls (131.5276,-0.3291) and (29.6371,22.9015) .. (47.7644,90.9328) .. controls (49.6989,62.9120) and (80.4610,40.0060) .. (101.1924,59.4599) .. controls (128.6626,85.2375) and (139.4074,111.8552) .. (145.7190,108.2466) -- cycle;
}

\newcommand{\addwizzard}{
    \path[fill=BlueViolet!50!Pink,line width=1pt,yshift=-40pt,rotate=5,xshift=32pt] 
    (20,100)--(60,0)--(100,100);
    \pgftext[at=\pgfpoint{71}{-15}, left, base]{\color{Gold}\EightStarBold}
    \pgftext[at=\pgfpoint{63}{0}, left, base]{\color{Gold}\EightStarBold~\EightStarBold}
    \pgftext[at=\pgfpoint{56}{15}, left, base]{\color{Gold}\EightStarBold~\EightStarBold~\EightStarBold}
    \pgftext[at=\pgfpoint{56}{30}, left, base]{\color{Gold}\EightStarBold~\EightStarBold~\EightStarBold}
    \draw[line width=6pt,color=black] (90,160) -- (60,210);
    \draw[line width=6pt,color=white] (85,168.333) -- (80,176.666);
}

\newcommand{\makeeinstein}[1]{
    \path[fill=#1,xshift=-4pt] (24.7738,59.7679) .. controls (31.3318,44.0108) and (53.1939,44.5256) .. (52.1285,41.2094) .. controls (51.4718,28.9400) and (30.1562,26.0780) .. (30.1562,26.0780) .. controls (48.5184,20.6686) and (79.2723,56.9617) .. (62.4298,11.1490) .. controls (65.1702,13.6709) and (88.0663,32.6096) .. (85.8201,7.5499) .. controls (87.7073,21.1456) and (96.9496,45.9959) .. (104.3286,23.2724) .. controls (113.1425,-15.9325) and (101.8773,49.6572) .. (138.4988,13.8484) .. controls (141.5713,17.0755) and (121.2714,39.5689) .. (139.2365,36.1290) .. controls (136.0271,66.8833) and (155.4874,23.7659) .. (155.4874,23.7659) .. controls (155.4874,23.7659) and (151.7518,45.0675) .. (147.8705,54.3986) .. controls (147.8705,54.3986) and (173.2987,55.3029) .. (176.7812,61.7670) .. controls (124.2612,69.4624) and (206.6010,77.2343) .. (154.2298,77.2507) .. controls (158.6628,83.1536) and (135.1295,89.9115) .. (169.9992,90.5427) .. controls (93.3592,92.0258) and (132.6373,57.7941) .. (94.5654,45.5826) .. controls (60.1628,40.4228) and (57.2813,64.7295) .. (51.9497,70.3679) .. controls (53.2460,53.9344) and (41.0100,59.0530) .. (24.7738,59.7679) -- cycle;

    \draw[line width=5pt,color=#1,line cap=round] (96,80) -- (82,73);
    \draw[line width=5pt,color=#1,line cap=round] (50,69) -- (60,68);

}

\newcommand{\addbook}[2]{
        \path[fill=#1,rotate=20] (110,120) rectangle (150,180);
        \node[rotate=-20, color=white] at (73,180)  {\makebox[2cm][c]{#2}};
}

\newcommand{\addwater}[1]{
    \draw [decorate,decoration=snake, line width=3pt, color=#1] (0,200) -- (100,200);
    \draw [decorate,decoration=snake, line width=3pt, color=#1] (180,200) -- (220,200);
    \draw [decorate,decoration=snake, line width=3pt, color=#1] (50,210) -- (150,210);
    \draw [decorate,decoration=snake, line width=3pt, color=#1] (110,230) -- (250,230);
    \draw [decorate,decoration=snake, line width=3pt, color=#1] (20,240) -- (70,240);
    \draw [decorate,decoration=snake, line width=3pt, color=#1] (60,250) -- (250,250);
}


\begin{document}

% grumpy
\begin{tikzpicture}[y=0.80pt, x=0.80pt, yscale=-1.000000, xscale=1.000000, inner sep=0pt, outer sep=0pt]
    \grumpyduck{Gold}
\end{tikzpicture}
%
%Christian Hupfer
\begin{tikzpicture}[y=0.80pt, x=0.80pt, yscale=-1.000000, xscale=1.000000, inner sep=0pt, outer sep=0pt]
    \duck{Gold}
    \addwizzard
\end{tikzpicture}
%
% short hairs
\begin{tikzpicture}[y=0.80pt, x=0.80pt, yscale=-1.000000, xscale=1.000000, inner sep=0pt, outer sep=0pt]
    \duck{Wheat}
    \addtshirt{LightBlue!50!white}
    \addshirt{LightSlateGrey}
    \addshorthair{brown!50!Grey}
\end{tikzpicture}
%
%Men in black
\begin{tikzpicture}[y=0.80pt, x=0.80pt, yscale=-1.000000, xscale=1.000000, inner sep=0pt, outer sep=0pt]
    \grumpyduck{Wheat}
    \addtshirt{white}
    \addshirt{black}
    \addtie{black}
    \addhat{black}
    \addsunglasses
\end{tikzpicture}
%

% ducklings
\begin{tikzpicture}[y=0.80pt, x=0.80pt, yscale=-0.6, xscale=0.6, inner sep=0pt, outer sep=0pt]
    \duck{Gold}
    \begin{scope}[xshift=300pt, scale=.3, yshift=400pt]
        \duck{Gold}
    \end{scope}
    \begin{scope}[xshift=180pt, scale=.3, yshift=350pt]
        \duck{Gold}
    \end{scope}
    \begin{scope}[xshift=240pt, scale=.3, yshift=450pt]
        \duck{Gold}
    \end{scope}     
\end{tikzpicture}
%
% samcarter
\begin{tikzpicture}[y=0.80pt, x=0.80pt, yscale=-1.000000, xscale=1.000000, inner sep=0pt, outer sep=0pt]
    \duck{Wheat!95!red}
    \addshirt{MidnightBlue}
    \addhair{OrangeRed!50!Brown}
\end{tikzpicture}
%
% hair
\begin{tikzpicture}[y=0.80pt, x=0.80pt, yscale=-1.000000, xscale=1.000000, inner sep=0pt, outer sep=0pt]
    \duck{Gold}
    \addhair{SeaGreen}
\end{tikzpicture}
%
% unicorn
\begin{tikzpicture}[y=0.80pt, x=0.80pt, yscale=-1.000000, xscale=1.000000, inner sep=0pt, outer sep=0pt]
    \duck{Pink}
    \addhair{MediumVioletRed}
    \addunicorn
\end{tikzpicture}

% icecream
\begin{tikzpicture}[y=0.80pt, x=0.80pt, yscale=-1.000000, xscale=1.000000, inner sep=0pt, outer sep=0pt]
    \duck{Gold}
    \addicecream{Wheat}{Plum}{Chocolate}
\end{tikzpicture}
%
% sunglasses
\begin{tikzpicture}[y=0.80pt, x=0.80pt, yscale=-1.000000, xscale=1.000000, inner sep=0pt, outer sep=0pt]
    \duck{Gold}
    \addsunglasses
\end{tikzpicture}
%
% normal duck
\begin{tikzpicture}[y=0.80pt, x=0.80pt, yscale=-1.000000, xscale=1.000000, inner sep=0pt, outer sep=0pt]
    \duck{Gold}
\end{tikzpicture}
% blue duck
\begin{tikzpicture}[y=0.80pt, x=0.80pt, yscale=-1.000000, xscale=1.000000, inner sep=0pt, outer sep=0pt]
    \duck{SteelBlue}
\end{tikzpicture}

% alien duck
\begin{tikzpicture}[y=0.80pt, x=0.80pt, yscale=-1.000000, xscale=1.000000, inner sep=0pt, outer sep=0pt]
    \duck{Gold}
    \addalien
\end{tikzpicture}
%
% hat duck
\begin{tikzpicture}[y=0.80pt, x=0.80pt, yscale=-1.000000, xscale=1.000000, inner sep=0pt, outer sep=0pt]
    \duck{Gold}
    \addhat{SaddleBrown}
\end{tikzpicture}
%
% swimming
\begin{tikzpicture}[y=0.80pt, x=0.80pt, yscale=-1.000000, xscale=1.000000, inner sep=0pt, outer sep=0pt]
    \duck{Gold}
    \addwater{blue!50!cyan} 
\end{tikzpicture}
%
% Brazil colour duck for Paulo
\begin{tikzpicture}[y=0.80pt, x=0.80pt, yscale=-1.000000, xscale=1.000000, inner sep=0pt, outer sep=0pt]
    \definecolor{brazilgreen}{RGB}{0,155,58}
    \definecolor{brazilyellow}{RGB}{254,223,0}
    \definecolor{brazilblue}{RGB}{0,39,118}
    \duck{brazilyellow}
    \addshirt{brazilblue}
    \addshorthair{brazilgreen}
\end{tikzpicture}

% prof. van duck
\begin{tikzpicture}[y=0.80pt, x=0.80pt, yscale=-1.000000, xscale=1.000000, inner sep=0pt, outer sep=0pt]
    \duck{Gold!40!white}
    \makeeinstein{gray!50!white}
    \addglasses{brown!70!black}
    \addbook{brown!70!black}{\TeX}
\end{tikzpicture}

\end{document}

答案2

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{tikzpeople}
\begin{document}
\begin{tikzpicture}
\node[duck,evil,minimum size=1.5cm] (B){};
\end{tikzpicture}
\end{document}

在此处输入图片描述

沒有代碼...

在此处输入图片描述

答案3

这是我到目前为止所做的(当然还有待改进)。

在此处输入图片描述

这是我的tikzducks.sty

\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{tikzducks}[2016/01/05 All we need is\dots ducks!]

\RequirePackage{tikz}
\usetikzlibrary{shapes.geometric,shapes.symbols,positioning,decorations.pathmorphing}
\usetikzlibrary{shapes,arrows,decorations.markings}

\RequirePackage{halloweenmath}

\tikzset{%
    pics/wing/.style={code={%
        \draw[fill=yellow] (0,0) to[bend right] (1,0) to[bend left] (.7,-.6) to[bend left] cycle;
    }}, 
    pics/eye/.style={code={%
        \draw[fill=white] (-.1,-.05) ellipse (.3 and .2);
        \draw[fill=black] (0,0) circle[radius=.1];
    }},
    pics/paw/.style={code={%
        \draw[fill=orange] (0,0) -- (0,.8) -- (.1,.8) -- (.1,.05) -- (.8,.05) to[bend right] (.7,-.2) to[bend right] (.6,-.45) -- cycle;
    }},
    pics/body/.style={code={%
        \draw[fill=yellow] (0,0) to[bend right] (.6,-1.2) to[bend right] (2,-2.4) to[bend right=70, smooth] (3.7,-.1) to[bend left] cycle;
    }},
    pics/head/.style={code={%
        \draw[fill=yellow] (0,0) circle[radius=.9];
    }},
    pics/closedbeak/.style={code={%
        \draw[fill=orange] (0,0) -- (-.35,.1) -- (-.65,-.3) -- (-.1,-.7) to[bend right=70] (.2,-.5) -- cycle;
    }},
    pics/openbeak/.style={code={%
        \draw[fill=orange] (0,0) -- (.5,.35) to[bend left=70] (.55,.25) -- (.23,-.29) -- (.3,-.7) to[bend left=70] (.25,-.75) -- (-.01,-.45) -- cycle;
    }},
    create duck coordinates/.style = {insert path={(0,0) coordinate (duck)}},
    pics/duck/.style={code={%
        \pic[rotate=30] at (.5,-1.8) {paw};
        \pic at (-2.5,1) {body};
        \pic at (-1,0) {wing};
        \pic at (1.5,1) {head};
        \pic at (2.2,.8) {closedbeak};
        \pic[rotate=300] at (1.6,.9) {eye};
        \pic[xscale=1,yscale=-1,rotate=75] at (1.91,1.08) {eye};
        \path (-1,-1.8) coordinate (paw);
        \pic[rotate=330] at (paw) {paw};
    }},
    create duckwithopenbeak coordinates/.style = {insert path={(0,0) coordinate (duckwithopenbeak)}},
    pics/duckwithopenbeak/.style={code={%
        \pic[rotate=30] at (.5,-1.8) {paw};
        \pic at (-2.5,1) {body};
        \pic at (-1,0) {wing};
        \pic at (1.5,1) {head};
        \pic[rotate=300] at (1.94,1.06) {eye};
        \pic[rotate=-20] at (2.4,.9) {openbeak};
        \path (-1,-1.8) coordinate (paw);
        \pic[rotate=330] at (paw) {paw};
    }},
    create bow coordinates/.style = {insert path={(1.3,1.8) coordinate (bow)}},
    pics/bow/.style={code={%
        \draw[red, fill=pink, rounded corners] (0,0) -- (.7,.55) -- (.7,-.55) -- cycle;
        \draw[red, fill=pink, rounded corners] (0,0) -- (-.7,.55) -- (-.7,-.55) -- cycle;
        \draw[red, fill=pink] (0,0) circle [radius=1/4];
    }},
    pics/daisy/.style={code={%
        \foreach \i in {0,45,...,325}
            \draw[blue, fill=white, rotate=\i]
                (0,0) .. controls ++(-30:1/2) and ++(30:1/2) .. cycle;
            \draw[orange, fill=yellow] circle [radius=1/8];
    }},
    create nacklace coordinates/.style = {insert path={(.6,.7) coordinate (nacklace)}},
    pics/nacklace/.style={code={%
        \path (0,0) coordinate (nacklacebase);
        \pic at (nacklacebase) {daisy};
        \pic[below right=1em and 1em of nacklacebase] {daisy};
        \pic[below right=2em and 2em of nacklacebase] {daisy};
    }},
    create blackboard coordinates/.style = {insert path={(3.5,1.8) coordinate (blackboard)}},
    pics/blackboard/.style={code={%
        \node at (0,0) [rectangle, fill=black, draw=brown, very thick,font={\color{white}\bfseries\small},minimum height=10ex] {$ax^2+bx+c=0$};
    }},
    create glasses coordinates/.style = {insert path={(1.5,.8) coordinate (glasses)}},
    pics/glasses/.style={code={%
        \node [circle, draw=blue, very thick,minimum height=1.1em] (rglass) {};
        \node[right=.5em of rglass, circle, draw=blue, very thick,minimum height=1.1em] (lglass) {};
        \coordinate[above left=.1em and .9em of rglass] (rrglass);
        \coordinate[below left=.5em and .1em of rrglass] (rrrglass);
        \coordinate[above right=.1em and .9em of lglass] (llglass);
        \coordinate[below right=.5em and .1em of llglass] (lllglass);
        \draw[draw=blue, very thick] (rglass) -- (lglass);
        \draw[draw=blue, very thick] (rglass) -- (rrglass) -- (rrrglass);
        \draw[draw=blue, very thick] (lglass) -- (llglass) -- (lllglass);
    }},
    create soccerball coordinates/.style = {insert path={(2.6,-1.1) coordinate (soccerball)}},
    pics/soccerball/.style={code={%
        \draw[fill=white] (0,0) circle [radius=.9];
        \begin{scope}
            \clip (0,0) circle [radius=.9];
            \foreach \i in {-.4,.4}
            \node[regular polygon,regular polygon sides=6,fill=black,minimum height=3.5ex] at (\i,.4) {};
            \foreach \i in {-.8,0,.8} 
            \node[regular polygon,regular polygon sides=6,fill=black,minimum height=3.5ex] at (\i,-.4) {};
        \end{scope}
    }},
    create befana coordinates/.style = {insert path={(0,0) coordinate (befana)}},
    pics/befana/.style={code={%
        \node {$\displaystyle\mathwitch$};
    }},
    create ghost coordinates/.style = {insert path={(-.8,-.12) coordinate (ghost)}},
    pics/ghost/.style={code={%
        \node {$\xrightswishingghost{\mspace{30mu}}$};
    }},
    create help coordinates/.style = {insert path={(4.6,2.3) coordinate (help)}},
    pics/help/.style={code={%
        \node[draw, fill=white, shape=starburst, text width=5.7em, text centered] (helpnode) {%
                Help! \\ A \texttt{\textbackslash phantom}!
            };
        \coordinate[below left=-.1em and -0.3em of helpnode] (lhelpnode);
        \coordinate[below right=0.35em and -1.5em of helpnode] (rhelpnode);
        \coordinate[below left=2.3em and 1.1em of helpnode] (bhelpnode);
        \coordinate[below left=-.3em and -0.4em of helpnode] (llhelpnode);
        \coordinate[below right=0em and -.9em of helpnode] (rrhelpnode);
        \path[fill=white] (llhelpnode) -- (bhelpnode) -- (rrhelpnode);  
        \draw[fill=white] (lhelpnode) -- (bhelpnode) -- (rhelpnode);
    }},
    create righttooth coordinates/.style = {insert path={(2.11,.1) coordinate (righttooth)}},
    create lefttooth coordinates/.style = {insert path={(2.29,.15) coordinate (lefttooth)}},
    pics/tooth/.style={code={%
        \draw[fill=white] (0,0) -- (.05,-.2) -- (.11,.1);
    }},
    create cloak coordinates/.style = {insert path={(.65,.69) coordinate (cloak)}},
    pics/cloak/.style={code={%
        \draw[white,fill=black] (0,0) to[bend left=10] (-2.1,.1) 
            decorate [decoration={snake, segment length=10pt, amplitude=3pt}] 
            {to  (-2,-1.4)}   to[bend left=9]  (.3,-.4)  to[bend left=30] cycle;
        \draw[white,fill=black] (0,0) to[bend left=10] (-.1,.7) to[bend right=15] (.7,-.3) -- (.3,-.4) to[bend left=30] cycle;
    }},
    pics/batflock/.style={code={%
    \path[postaction={decorate,decoration={markings,
            mark=at position 0.01 with {\node[scale=0.4,rotate=-50] {$\mathbat$};},
            mark=at position 0.04 with {\node[scale=0.5,rotate=-40] {$\mathbat$};},
            mark=at position 0.07 with {\node[scale=0.6,rotate=-35] {$\mathbat$};},
            mark=at position 0.11 with {\node[scale=0.7,rotate=-30] {$\mathbat$};},
            mark=at position 0.15 with {\node[scale=0.8,rotate=-20] {$\mathbat$};},
            mark=at position 0.20 with {\node[scale=0.9,rotate=-10] {$\mathbat$};},
            mark=at position 0.25 with {\node[scale=1.0,rotate=5] {$\mathbat$};},
            mark=at position 0.31 with {\node[scale=1.1,rotate=15] {$\mathbat$};},
            mark=at position 0.38 with {\node[scale=1.2,rotate=15] {$\mathbat$};},
            mark=at position 0.44 with {\node[scale=1.3,rotate=0] {$\mathbat$};},
            mark=at position 0.50 with {\node[scale=1.4,rotate=-15] {$\mathbat$};},
            mark=at position 0.57 with {\node[scale=1.5,rotate=-25] {$\mathbat$};},
            mark=at position 0.65 with {\node[scale=1.6,rotate=-30] {$\mathbat$};}, 
            mark=at position 0.73 with {\node[scale=1.7,rotate=-35] {$\mathbat$};}, 
            mark=at position 0.81 with {\node[scale=1.8,rotate=-40] {$\mathbat$};},     
            mark=at position 0.89 with {\node[scale=1.9,rotate=-42] {$\mathbat$};},     
        }}] plot[smooth, tension=1] coordinates {(0,0) (2.5,1) (1,3) (7,4.5)};
    \path[postaction={decorate,decoration={markings,
            mark=at position 0.01 with {\node[scale=0.4,rotate=10] {$\xleftflutteringbat{\mspace{30mu}}$};},
            mark=at position 0.06 with {\node[scale=0.5,rotate=10] {$\xleftflutteringbat{\mspace{30mu}}$};},
            mark=at position 0.11 with {\node[scale=0.6,rotate=10] {$\xleftflutteringbat{\mspace{30mu}}$};},
            mark=at position 0.17 with {\node[scale=0.7,rotate=10] {$\xleftflutteringbat{\mspace{30mu}}$};},
            mark=at position 0.23 with {\node[scale=0.8,rotate=5] {$\xleftflutteringbat{\mspace{30mu}}$};},
            mark=at position 0.30 with {\node[scale=0.9,rotate=0] {$\xleftflutteringbat{\mspace{30mu}}$};},
            mark=at position 0.38 with {\node[scale=1.0,rotate=-10] {$\xleftflutteringbat{\mspace{30mu}}$};},
            mark=at position 0.48 with {\node[scale=1.1,rotate=-20] {$\xleftflutteringbat{\mspace{30mu}}$};},
            mark=at position 0.58 with {\node[scale=1.2,rotate=-30] {$\xleftflutteringbat{\mspace{30mu}}$};},
            mark=at position 0.68 with {\node[scale=1.3,rotate=-40] {$\xleftflutteringbat{\mspace{30mu}}$};},
            mark=at position 0.79 with {\node[scale=1.4,rotate=-41] {$\xleftflutteringbat{\mspace{30mu}}$};},
            mark=at position 0.90 with {\node[scale=1.5,rotate=-42] {$\xleftflutteringbat{\mspace{30mu}}$};},
        }}] plot[smooth, tension=1] coordinates {(1.7,1.3) (0,2.7) (2,4.5) (5,5.5)};
    \path[postaction={decorate,decoration={markings,
            mark=at position 0.16 with {\node[scale=0.4,rotate=-5] {$\xrightflutteringbat{\mspace{30mu}}$};},
            mark=at position 0.25 with {\node[scale=0.5,rotate=-25] {$\xrightflutteringbat{\mspace{30mu}}$};},
            mark=at position 0.34 with {\node[scale=0.6,rotate=-36] {$\xrightflutteringbat{\mspace{30mu}}$};},
            mark=at position 0.44 with {\node[scale=0.7,rotate=-38] {$\xrightflutteringbat{\mspace{30mu}}$};},
            mark=at position 0.55 with {\node[scale=0.8,rotate=-40] {$\xrightflutteringbat{\mspace{30mu}}$};},
            mark=at position 0.67 with {\node[scale=0.9,rotate=-42] {$\xrightflutteringbat{\mspace{30mu}}$};},
            mark=at position 0.81 with {\node[scale=1.0,rotate=-46] {$\xrightflutteringbat{\mspace{30mu}}$};},
            mark=at position 0.95 with {\node[scale=1.1,rotate=-50] {$\xrightflutteringbat{\mspace{30mu}}$};},
        }}] plot[smooth, tension=1] coordinates {(2.5,2) (2,2.7) (6.5,3.3)};
    }},
}

\newcommand{\duck}{%
    \begin{tikzpicture}
        \pic {duck};
    \end{tikzpicture}
}

\newcommand{\daisyduck}{%
    \begin{tikzpicture}
        \pic {duck};
        \path[create nacklace coordinates];
        \pic at (nacklace) {nacklace};  
    \end{tikzpicture}
}

\newcommand{\femaleduck}{%
    \begin{tikzpicture}
        \pic {duck};
        \path[create bow coordinates];
        \pic[rotate=35] at (bow) {bow}; 
    \end{tikzpicture}
}

\newcommand{\mathduck}{%
    \begin{tikzpicture}
        \path[create blackboard coordinates];
        \pic at (blackboard) {blackboard};
        \pic {duck};
        \path[create glasses coordinates];
        \pic[rotate=30, transform shape] at (glasses) {glasses};
    \end{tikzpicture}
}

\newcommand{\soccerduck}{%
    \begin{tikzpicture}
        \pic {duck};
        \path[create soccerball coordinates];
        \pic[rotate=30] at (soccerball) {soccerball};
    \end{tikzpicture}
}

\newcommand{\befanaduck}{%
    \begin{tikzpicture}
        \path[use as bounding box] (-2.5,-1.5) rectangle (2.5,1.5);  
        \pic[scale=.45,transform canvas={scale=.45},transform shape,rotate=20] at (3.17,1.59) {duck};
        \path[create befana coordinates];
        \pic[transform canvas={scale=4}] at (befana) {befana};
        \pic[rotate=330,scale=.45,transform canvas={scale=.45},transform shape,rotate=20] at (paw) {paw};
    \end{tikzpicture}
}

\newcommand{\ghostduck}{%
    \begin{tikzpicture}
        \path[use as bounding box] (-6,-2.5) rectangle (6,2.5);  
        \path[create ghost coordinates];
        \pic[transform canvas={scale=7}] at (ghost) {ghost};
        \pic {duckwithopenbeak};
        \path[create help coordinates];
        \pic at (help) {help};
    \end{tikzpicture}
}

\newcommand{\vampireduck}{%
    \begin{tikzpicture}
        \pic at (-6,-1) {batflock};
        \path[create righttooth coordinates];
        \pic at (righttooth) {tooth};
        \path[create lefttooth coordinates];
        \pic at (lefttooth) {tooth};
        \pic {duck};
        \path[create cloak coordinates];
        \pic at (cloak) {cloak};
        \pic at (-1,0) {wing};
    \end{tikzpicture}
}

这是演示的代码:

% arara: pdflatex
% arara: convert: {density: 160, otheroptions: -dispose previous -delay 140 -loop 1, format: gif}
\documentclass{beamer}
\usepackage{cprotect}
\usepackage{tikzducks}

\usetheme{Madrid}
\setbeamertemplate{navigation symbols}{}
\cprotect\title{Quack guide to \verb|tikzducks| package}
\subtitle{Actually, some examples to be improved and transformed into a package}
\author{Car\LaTeX}
\institute{Duck fan club}

\begin{document}
\begin{frame}[plain]
    \titlepage
\end{frame}
\begin{frame}[fragile=singleslide]
    \frametitle{Standard version}
    Command: 
    \begin{center}
        \verb|\duck|
    \end{center}
    Result:
    \begin{figure}
        \centering
        \duck   
    \end{figure}
\end{frame}
\begin{frame}[fragile=singleslide]
    \frametitle{Female version}
    Command: 
    \begin{center}
    \verb|\femaleduck|
    \end{center}
    Result:
    \begin{figure}
    \centering
    \femaleduck
    \end{figure}
    Accessory \verb|pic| available: \verb|bow| 
    \begin{tikzpicture}
    \pic[scale=.7, transform canvas={scale=.7}] at (.6,.2) {bow};
    \end{tikzpicture}
\end{frame}
\begin{frame}[fragile=singleslide]
    \frametitle{Daisy version}
    Command: 
    \begin{center}
    \verb|\daisyduck|
    \end{center}
    Result:
    \begin{figure}
    \centering
    \daisyduck
    \end{figure}
    Accessory \verb|pic|s available: \verb|daisy| 
    \begin{tikzpicture}
    \pic[scale=.75, transform canvas={scale=.75}] at (.35,.25) {daisy};
    \end{tikzpicture} 
    \hspace{1em} and \verb|nacklace| 
    \begin{tikzpicture}
    \pic[scale=.5, transform canvas={scale=.5}] at (.5,1) {nacklace};
    \end{tikzpicture}\\
\end{frame}
\begin{frame}[fragile=singleslide]
    \frametitle{Mathematician version}
    Command: 
    \begin{center}
    \verb|\mathduck|
    \end{center}
    Result:
    \begin{figure}
    \centering
    \mathduck
    \end{figure}
    Accessory \verb|pic|s available:
    \verb|glasses| 
    \begin{tikzpicture}
    \pic[scale=.5, transform canvas={scale=.5}] at (.7,.2) {glasses};
    \end{tikzpicture}
    \hspace{2.4em} and \verb|blackboard| 
    \begin{tikzpicture}
    \pic[scale=.4, transform canvas={scale=.4}] at (1.4,.5) {blackboard};
    \end{tikzpicture}\\
\end{frame}
\begin{frame}[fragile=singleslide]
    \frametitle{Soccer player version}
    Command: 
    \begin{center}
    \verb|\soccerduck|
    \end{center}
    Result:
    \begin{figure}
    \centering
    \soccerduck
    \end{figure}
    Accessory \verb|pic| available: \verb|soccerball| 
    \begin{tikzpicture}
    \pic[scale=.5,transform canvas={scale=.5},transform shape] at (.5,.3) {soccerball};
    \end{tikzpicture}\\ 
\end{frame}
\begin{frame}[fragile=singleslide]
    \frametitle{The Befana duck\dots}
    Using \verb|\displaystyle\mathwitch| $\displaystyle\mathwitch$ from the gorgeous Gustavo Mezzetti's package \verb|halloweenmath|, here is the Befana\footnote{For anyone who doesn't know who the Befana is, she's a sort of female version of Santa Claus, who brings gifts or coal (to good and bad children, respectively) every year on January, 6\textsuperscript{th}.} duck!

    Command: 
    \begin{center}
    \verb|\befanaduck|
    \end{center}
    Result:
    \begin{figure}
    \centering
    \befanaduck
    \end{figure}
\end{frame}
\begin{frame}[fragile=singleslide]
    \frametitle{\dots the ghost duck\dots}
    Using \verb|\xrightswishingghost| $\xrightswishingghost{}$, again from \verb|halloweenmath| package, here is the ghost duck!\\
    Command: 
    \begin{center}
    \verb|\ghostduck|
    \end{center}
    Result:
    \begin{figure}
    \centering
    \resizebox{0.7\textwidth}{!}{%
    \ghostduck
    }
    \end{figure}
\end{frame}
\begin{frame}[fragile=singleslide]
    \frametitle{\dots and the vampire duck!}
    The vampire duck, with bats from \verb|halloweenmath| package!

    Command: 
    \begin{center}
    \verb|\vampireduck|
    \end{center}
    Result:
    \begin{figure}
    \centering
    \resizebox{0.5\textwidth}{!}{%
    \vampireduck
    }
    \end{figure}
\end{frame}
\end{document}

答案4

我确信有人会抱怨这个答案不够严肃,与这个网站的崇高目标不符。对于批评者,我说,你显然花在河里闲逛的时间太少了。

与灵魂伴侣的真爱......

\documentclass[border=10pt,x11names,dvipsnames,svgnames]{standalone}
\usepackage{tikz}
\usetikzlibrary{decorations.pathmorphing}
\newcounter{duckno}
\tikzset{
  hwyaden/.pic={
    \tikzset{hwyaden/.cd, shading/.style={#1}}
    \stepcounter{duckno}
    \begin{scope}[local bounding box/.expanded=h\theduckno]
      \shade [hwyaden/shading] (0,0) -- (-\mathhwyaden,0) -- (120:{6*\mathhwyaden}) arc (120:60:{6*\mathhwyaden}) -- (\mathhwyaden,0) -- cycle;
    \end{scope}
    \clip ([yshift={-4*\mathhwyaden},xshift={-2*\mathhwyaden}]h\theduckno.south west) coordinate (a) rectangle ([yshift={6*\mathhwyaden}, xshift={2*\mathhwyaden}]h\theduckno.east |- a) coordinate (e);
    \shade [top color=blue!50!cyan, bottom color=blue!75!black!25, middle color=blue!50!black, decorate, decoration={snake, amplitude=1pt, segment length=\mathhwyaden}] ([xshift=\mathhwyaden, yshift=-\mathhwyaden]e) -|  ([xshift=-\mathhwyaden, yshift=-\mathhwyaden]a) -| cycle;
  },
  hwyaden/.search also={/tikz/},
  hwyaden/.cd,
  shading/.style=black,
  size/.store in=\mathhwyaden,
  size=10pt,
}
\begin{document}
\begin{tikzpicture}
  \pic {hwyaden={ball color=brown, postaction={outer color=Brown, inner color=Apricot, opacity=.5}}};
  \pic at (60pt,0) {hwyaden={preaction={outer color=DarkGreen, inner color=ForestGreen, opacity=1}, ball color=LimeGreen, opacity=.75, postaction={outer color=DarkGreen, inner color=Gold, opacity=.75}}};
  \node (d) [anchor=mid west, white, font=\itshape\bfseries, align=left] at ([yshift={-5*\mathhwyaden}]h1.west) {Heads down, tails up,\\Dabbling free!};
  \node [white, anchor=north east, font=\footnotesize\itshape] at (d.south -| current bounding box.east) {--- Kenneth Grahame};
\end{tikzpicture}
\end{document}

一只鸭子和她的公鸭......

鸭子与德雷克

相关内容