我们中间有一个 TikZ 冒名顶替者。

我们中间有一个 TikZ 冒名顶替者。

我们中间有一个 TikZ 冒名顶替者。


背景

在了解了一些令人惊叹的 TikZ 软件包之后tikzduckstikzpeopletikzsymbols通过下面我给出的一些例子,我收获了一些启发,开始学习一些技巧,以便能够创建我自己的一套灵活的 TikZ 绘图。

\documentclass{article}
\usepackage{tikz}
\usepackage{tikzducks}
\usepackage{tikzpeople}
\usepackage{tikzsymbols}
\begin{document}
\begin{tikzpicture}
  \duck;
  \duck[body=blue,scale=.3, xshift=150pt];
  \node[duck] at (2,0) {};
  \node at (3,0) {\Smiley[2] \dNinja[2][green!50!black][blue]};
  \node at (4,0) {\Strichmaxerl[5]};
  \node[red] at (5,0) {\Strichmaxerl[5][45]};
\end{tikzpicture}
\end{document}

在此处输入图片描述

当我刚刚有了顿悟的时候……


在我们之间

...“我可以画一个我们之中的船员在 TikZ 中!”。

基本草图来自这个视频:如何在我们中间绘画。我还检查了一些想法画躯干

在此处输入图片描述


问题

为了将这个基本草图演变成值得成为 TikZ 包的东西,可以进行哪些改进?

例如,tikzducks具有tikzpeople许多可选的额外功能,尽管tikzsymbols采用了完全不同的方法,但tikzsymbols仍然有一些有趣的选项。

我将用自己的答案作为初步的草图。

答案1

我想在我们之间这样做:

\documentclass[tikz]{standalone}
\usepackage{xcolor}
\begin{document}
\begin{tikzpicture}
   \fill
   (5.44,4.97) .. controls (5.70,3.67) and (5.50,1.48) ..
   (5.36,0.86) .. controls (5.22,0.68) and (4.92,0.63) ..
   (4.24,0.58) .. controls (3.83,0.99) and (3.85,1.38) ..
   (3.83,1.69) .. controls (3.68,1.74) and (3.67,1.75) ..
   (3.46,1.69) .. controls (3.39,1.28) and (3.48,0.93) ..
   (3.42,0.52) .. controls (2.90,0.10) and (2.09,0.00) ..
   (1.80,0.21) .. controls (1.55,0.39) and (1.51,0.86) ..
   (1.54,1.56) .. controls (1.32,1.61) and (0.84,1.36) ..
   (0.52,1.83) .. controls (0.00,2.61) and (0.01,4.97) ..
   (0.16,5.23) .. controls (0.32,5.49) and (0.79,5.54) ..
   (1.09,5.60) .. controls (1.18,6.01) and (0.94,7.41) ..
   (2.37,7.75) .. controls (4.11,8.12) and (4.80,7.09) ..
   (4.89,6.71) .. controls (5.49,6.61) and (5.88,5.57) ..
   (5.44,4.97) -- cycle;
   \shade[top color=red, bottom color=red!40!black]
   (3.48,7.36) .. controls (3.76,7.33) and (4.10,7.04) ..
   (4.30,6.81) .. controls (3.35,6.76) and (2.20,6.73) ..
   (2.31,5.90) .. controls (2.36,5.54) and (2.44,3.40) ..
   (5.04,4.68) .. controls (5.35,2.16) and (5.01,2.05) ..
   (5.01,1.79) .. controls (5.01,1.61) and (5.14,1.48) ..
   (5.06,1.09) .. controls (4.83,1.01) and (4.57,0.88) ..
   (4.28,0.96) .. controls (4.05,1.35) and (4.28,1.51) ..
   (4.20,1.79) .. controls (4.41,1.84) and (4.54,1.92) ..
   (4.65,2.13) .. controls (4.02,1.97) and (3.19,2.16) ..
   (3.06,2.00) .. controls (2.93,1.77) and (3.09,1.38) ..
   (3.06,0.86) .. controls (2.72,0.47) and (2.42,0.44) ..
   (2.05,0.60) .. controls (1.89,1.22) and (1.68,2.62) ..
   (1.60,3.30) .. controls (1.27,5.48) and (1.47,6.39) ..
   (1.71,6.78) .. controls (1.97,7.43) and (3.19,7.38) ..
   (3.48,7.36) -- cycle
   (0.56,5.07) .. controls (0.77,5.17) and (0.93,5.15) ..
   (1.14,5.15) .. controls (1.03,4.34) and (1.08,2.78) ..
   (1.42,1.92) .. controls (1.14,1.84) and (1.06,1.95) ..
   (0.77,2.05) .. controls (0.43,2.88) and (0.43,4.58) ..
   (0.56,5.07) -- cycle;
   \shade[top color=blue!20, bottom color=blue!20!black]
   (2.84,6.11) .. controls (3.07,6.37) and (4.06,6.58) ..
   (4.61,6.37) .. controls (5.15,6.16) and (5.44,5.85) ..
   (5.21,5.38) .. controls (4.97,4.91) and (3.67,4.50) ..
   (3.15,4.94) .. controls (2.63,5.38) and (2.61,5.85) ..
   (2.84,6.11) -- cycle;
   \end{tikzpicture}
\end{document}

我们之中的红色人物

答案2

下面的草图有一个newcommand插入 TikZ 代码来绘制一个我们之中的船员

这不是一个功能齐全的设计,但有颜色和两种情感可供选择:angryvery angry

这只是一个开始,以便(有一天)能够变得和其他软件包一样好。

\documentclass{article}
\usepackage{tikz}
\usepackage{xifthen}

\newcommand{\FHZamongUs}[3][]{%
\begin{tikzpicture}[every path/.style={very thick}]
  % Backpack
  \draw[fill=#2, rounded corners = 3mm] (1,1) rectangle ++(0.8,3.2);
  % Body
  \draw[fill=#2, rounded corners = 3mm] (1.5,0) -- (1.5,5)
  arc (124.8074:103.8454:5) arc (80.6307:58.1808:5)-- (5,0) -- (3.7,0)
  {[rounded corners = 0mm] -- (3.7,1) coordinate(A) -- (2.7,1)}
  -- (2.7,0) -- cycle;
  % Eyes
  \ifthenelse{\equal{#1}{angry}}
    {\draw[fill=#3]  plot[smooth cycle, tension=.7] coordinates
      {(4.3,4.7) (5.2,4.6) (5.2,3.5) (4.2,3.2) (3.1,3.5) (3.1,4.7)};}
    {\ifthenelse{\equal{#1}{very angry}}
      {\draw[fill=#3]  plot[smooth cycle, tension=.7] coordinates
        {(4.4,4.3) (5.2,4.6) (5.2,3.5) (4.2,3.6) (3.1,3.5) (3.1,4.7)};}
      {\draw[fill=#3]  plot[smooth cycle, tension=.7] coordinates
        {(4.3,4.9) (5.2,4.6) (5.2,3.5) (4.2,3.2) (3.1,3.5) (3.1,4.7)};}
    }
  % Leg detail
  \draw plot[smooth, tension=.7] coordinates {(A) (3.9,1) (4.2,1.1)};
\end{tikzpicture}
}

\begin{document}
  \FHZamongUs{white}{white}
  \FHZamongUs[angry]{yellow}{white}
  \FHZamongUs[very angry]{red}{cyan}
\end{document}

在此处输入图片描述


更新

带阴影的新风格

使用来自scope内部的想法newcommand这个答案和阴影样式来自这个视频,我将之前的绘图更新为一种拆分每个部分并创建newcommands 来组合它们的样式。

这仍然不是创建阴影的最佳方法,但结果和新的实现比以前的尝试要好得多。

我仍然打算添加一只手,以阴影风格创造情感,并将其作为包进行更新CTAN

文件FHZ-amongUs.sty

\NeedsTeXFormat{LaTeX2e}[1994/06/01]
\ProvidesPackage{FHZ-amongUs}[2020-10-18 Custom Package for my AmongUs sketch]

\RequirePackage{tikz}
\RequirePackage{xifthen}
\usetikzlibrary{calc}
\usetikzlibrary{shadings}

%  ======================================= Style 0 -- Original Idea
\newcommand{\FHZamongUsOriginal}[3][]{%
\begin{tikzpicture}[every path/.style={very thick}]
  % Backpack
  \draw[fill=#2, rounded corners = 3mm] (1,1) rectangle ++(0.8,3.2);
  % Body
  \draw[fill=#2, rounded corners = 3mm] (1.5,0) -- (1.5,5)
  arc (124.8074:103.8454:5) arc (80.6307:58.1808:5)-- (5,0) -- (3.7,0)
  {[rounded corners = 0mm] -- (3.7,1) coordinate(A) -- (2.7,1)}
  -- (2.7,0) -- cycle;
  % Eyes
  \ifthenelse{\equal{#1}{angry}}
    {\draw[fill=#3]  plot[smooth cycle, tension=.7] coordinates
      {(4.3,4.7) (5.2,4.6) (5.2,3.5) (4.2,3.2) (3.1,3.5) (3.1,4.7)};}
    {\ifthenelse{\equal{#1}{very angry}}
      {\draw[fill=#3]  plot[smooth cycle, tension=.7] coordinates
        {(4.4,4.3) (5.2,4.6) (5.2,3.5) (4.2,3.6) (3.1,3.5) (3.1,4.7)};}
      {\draw[fill=#3]  plot[smooth cycle, tension=.7] coordinates
        {(4.3,4.9) (5.2,4.6) (5.2,3.5) (4.2,3.2) (3.1,3.5) (3.1,4.7)};}
    }
  % Leg detail
  \draw plot[smooth, tension=.7] coordinates {(A) (3.9,1) (4.2,1.1)};
\end{tikzpicture}
}
%  =======================================

%  ======================================= Style I -- Manual Shade
\newcommand{\FHZamongUsPackbackI}[2][]{
  \begin{scope}[#1]
    \fill[#2, rounded corners = 3mm] (1,1) coordinate(R1) rectangle ++(0.8,3.2) coordinate(R2);
    \fill[black!30!#2, rounded corners = 3mm] (R1) -| ($(R2)+(0,-0.2)$)
    {[sharp corners]-- (1,3.5)}
    -- cycle;
    \draw[rounded corners = 3mm] (1,1) rectangle ++(0.8,3.2);
  \end{scope}
}
\newcommand{\FHZamongUsBodyI}[2][]{
  \begin{scope}[#1]
    \fill[black!30!#2, rounded corners = 3mm] (1.5,0) -- (1.5,5)
    arc (124.8074:103.8454:5) arc (80.6307:58.1808:5)-- (5,0) -- (3.7,0)
    {[rounded corners = 0mm] -- (3.7,1) -- (2.7,1)}
    -- (2.7,0) -- cycle;
    \fill[#2] plot[smooth, tension=.7]
    coordinates {(1.9436,5.2721) (2.0594,2.4257) (2.9347,1.3971)
      (4.4826,1.7343) (4.9666,3.0446) (4.9686,4.0294)
      (4.9797,4.7974) (4.6523,5.2436) (3.4183,5.6907) (2.5265,5.5757)};
    \draw[rounded corners = 3mm] (1.5,0) -- (1.5,5)
    arc (124.8074:103.8454:5) arc (80.6307:58.1808:5)-- (5,0) -- (3.7,0)
    {[sharp corners] -- (3.7,1) coordinate(A) -- (2.7,1)}
    -- (2.7,0) -- cycle;
    % Leg detail
    \draw plot[smooth, tension=.7] coordinates {(A) (3.9,1) (4.2,1.1)};
  \end{scope}
}
\newcommand{\FHZamongUsEyesI}[2][]{
  \begin{scope}[#1]
    \fill[#2] plot[smooth cycle, tension=.7] coordinates
    {(4.3,4.9) (5.2,4.6) (5.2,3.5) (4.2,3.2) (3.1,3.5) (3.1,4.7)};
    \fill[black!50!#2]
    {plot[smooth, tension=.7] coordinates {(3.1,4.7) (3.2964,4.8157) (3.2633,4.3111) (3.4423,3.8301)
        (3.794,3.6464) (4.3087,3.5904) (4.9485,3.5904) (5.2338,3.5723) (4.7492,3.2515) (3.5071,3.2661) (3.0208,3.6849) (2.9691,4.3844)}};
    \draw plot[smooth cycle, tension=.7] coordinates
    {(4.3,4.9) (5.2,4.6) (5.2,3.5) (4.2,3.2) (3.1,3.5) (3.1,4.7)};
    \fill[white] plot[smooth cycle, tension=0.7]
    coordinates {(4.3069,4.7316) (4.581,4.7457) (4.8219,4.7029) (4.9541,4.5887) (4.7168,4.5055) (4.3152,4.525) (4.168,4.6295)};
  \end{scope}
}
\newcommand{\FHZamongUsI}[3][]{
  \FHZamongUsPackbackI[#1]{#2};
  \FHZamongUsBodyI[#1]{#2};
  \FHZamongUsEyesI[#1]{#3};
}
%  =======================================

%  ======================================= Style II -- shade
\newcommand{\FHZamongUsPackbackII}[2][]{
  \begin{scope}[#1]
    \draw[shade, top color=#2, bottom color=#2!5!black, middle color=#2, rounded corners = 3mm]
    (1,1) rectangle ++(0.8,3.2);
  \end{scope}
}
\newcommand{\FHZamongUsBodyII}[2][]{
  \begin{scope}[#1]
    \draw[shade, top color=#2, bottom color=#2!5!black, middle color=#2,
    rounded corners = 3mm]
    (1.5,0) -- (1.5,5)
    arc (124.8074:103.8454:5) arc (80.6307:58.1808:5)-- (5,0) -- (3.7,0)
    {[rounded corners = 0mm] -- (3.7,1) coordinate(A) -- (2.7,1)}
    -- (2.7,0) -- cycle;
    % Leg detail
    \draw plot[smooth, tension=.7] coordinates {(A) (3.9,1) (4.2,1.1)};
  \end{scope}
}
\newcommand{\FHZamongUsEyesII}[2][]{
  \begin{scope}[#1]
    \draw[shade, inner color=white!95!black, outer color=#2]  plot[smooth cycle, tension=.7] coordinates
    {(4.3,4.9) (5.2,4.6) (5.2,3.5) (4.2,3.2) (3.1,3.5) (3.1,4.7)};
  \end{scope}
}
\newcommand{\FHZamongUsII}[3][]{
  \FHZamongUsPackbackII[#1]{#2};
  \FHZamongUsBodyII[#1]{#2};
  \FHZamongUsEyesII[#1]{#3};
}
%  =======================================

\endinput

文件main.tex

\documentclass{article}
\usepackage[margin=2cm,landscape]{geometry}
\usepackage{FHZ-amongUs}

\begin{document}
\begin{tikzpicture}
  \FHZamongUsPackbackI[shift={(0,0)}]{yellow};
  \FHZamongUsBodyI[shift={(0,0)}]{yellow};
  \FHZamongUsEyesI[shift={(0,0)}]{cyan};
  % ===========
  \FHZamongUsI[shift={(5,0)}]{red}{blue};
  \FHZamongUsI[shift={(10,0)}]{green}{gray};
  \FHZamongUsI[shift={(15,0)}]{blue}{orange};
  % ===========
  \FHZamongUsPackbackII[shift={(0,7)}]{yellow};
  \FHZamongUsBodyII[shift={(0,7)}]{yellow};
  \FHZamongUsEyesII[shift={(0,7)}]{cyan};
  % ===========
  \FHZamongUsII[shift={(5,7)}]{red}{blue};
  \FHZamongUsII[shift={(10,7)}]{green}{gray};
  \FHZamongUsII[shift={(15,7)}]{blue}{orange};
\end{tikzpicture}

\FHZamongUsOriginal{yellow}{cyan}
\FHZamongUsOriginal[angry]{yellow}{cyan}
\FHZamongUsOriginal{black}{white}
\FHZamongUsOriginal[angry]{gray}{white}
\FHZamongUsOriginal[very angry]{white}{black}
\end{document}

结果是:

在此处输入图片描述在此处输入图片描述


更新 2

可在 CTAN 购买

我更新了图纸、语法和名称,创建了一个现在可用的包https://www.ctan.org/pkg/tikz-among-us

该文档还介绍了一些有趣的应用程序,例如动画和页码。

相关内容