一位非常有创造力的教授曾经在讲授水平投掷课时画了这幅图。
哪个来源这个视频。
一旦我看到它,我就试图重现我自己所看到的绘图,不是很优雅,请在下面回答。
我的第一次尝试确实丑得令人难以置信。显然我对非技术绘图的技能不多。
然后我发现了这个有趣的图书馆口袋妖怪的精灵作为页码。
我确实发现非常巧妙的是每个神奇宝贝文件都被命名为一个数字,并且这个数字在相应的页面上使用。
我在第二次尝试中使用了这些精灵,这比第一次(糟糕的)尝试要好得多。
TikZ包
ducks
非常棒,它有很多选项,这让我很疑惑:我怎么能对口袋妖怪做类似的事情呢?我的意思是,创建命令来插入口袋妖怪,按名称和/或按数字以及一些选项。
我尝试\newcommand{\pikachu}{def}
使用def
作为里面的 TikZ 代码\begin{scope} \end{scope}
,但效果不太好。
我第三次尝试使用效果ducks
非常好。捕获不依赖外部数字的概念。
这就是为什么
ducks
问题所在。我想知道如何创建简单的命令来插入口袋妖怪,实际上,插入任何其他 tikz-define 命令或者一组预定义的图像。
我曾见过一件用 TikZ 制作的令人难以置信的艺术作品,它重现了TikZ 中的惊喜皮卡丘。这比这里的想法好多了,但也完全超出了我的能力范围。
版权法可能适用于官方的口袋妖怪精灵,也许类似于如果有人在 Wolfram Alpha 中搜索口袋妖怪,就会出现的情况,例如这只喷火龙可以在 TikZ 中使用。
我知道tikzpgf手册。虽然这是一本完整的手册,但直接从中学习一些技能并不是一件简单的任务。我记得当我学习了这些技能后,我的进步有多大scope
,然后我才能深入研究手册,知道我在寻找什么。
我并不是说我会自己开发它,但了解基础知识对于培养技能或在未来某一天做出贡献是一个良好的开端。
欢迎任何想法和建议。
答案1
.tex
这是我使用的主要代码
\documentclass{article}
\usepackage{amsmath}
\usepackage{graphicx}
\usepackage{tikz}
\usetikzlibrary{ducks}
\begin{document}
\input{fig_TikZ_parabola_Pikachu}
\end{document}
tikzpicture
因为我喜欢在单独的文件上创建s。这是fig_TikZ_parabola_Pikachu.tex
文件。
\begin{tikzpicture}
% --------------------
\draw (-1,0) -- (9,0);
\foreach \x in {-1,-0.5,...,9} {
\begin{scope}[xshift=\x cm, green!50!black, very thick]
\draw (0,0) -- ++(-0.15,-0.15);
\end{scope}
};
\draw[dashed](0,0) -- ++(0,5);
\draw (0,0) -- ++(0,-1);
\draw[latex-latex] (0,-0.8) -- node[midway,above]{$x = ?$} ++(7.2,0);
\draw (7.2,0) -- ++(0,-1);
% --------------------
% --------------------
\draw[scale=1,domain=0:7,smooth,variable=\x,violet,dotted,very thick] plot ({\x},{-0.08*(\x)^2 + 5});
% --------------------
% --------------------
\begin{scope}[shift={(-1,5)}]
\draw[fill=red] (0,0) -- ++(0.8,0) arc (180:0:0.2) -- ++(0.8,0) arc (-180:0:-1);
\draw[fill=white] (0,0) -- ++(0.8,0) arc (-180:0:0.2) -- ++(0.8,0) arc (180:0:-1);
\draw[fill=white] (1,0) circle (0.2);
\draw[fill=black] (1,0) circle (0.1);
\end{scope}
% --------------------
% --------------------
% Pikachu Figure -- cute -- 3rd attempt
%\draw (6,0) pic [] {duck};
% --------------------
% --------------------
% Pikachu Figure -- cute -- 2nd attempt
\node at (7.5,1.5) {\includegraphics[width=3cm]{pikachu.png}};
% --------------------
% --------------------
% Pikachu in TikZ -- terrible -- 1st attempt
%\begin{scope}[shift={(5,0)}]
% \draw[fill=yellow] (0.4,0) -- ++(2.9,0)
% .. controls (3.5,0.7) and (3.5,0.9) ..
% (3.2,1.6) -- (5.2,3.3) coordinate(OD) -- (2.7,1.8)
% .. controls (2,2.1) and (1.3,2.1) .. (0.7,1.8) --
% (-1.3,3.3) coordinate(OE) -- (0.2,1.5)
% .. controls (-0.1,0.8) and (-0.1,0.6) ..
% (0.1,0) -- cycle;
% % --------------------
% \draw[fill=red] (0.4,0.7) circle (0.2);
% \draw[fill=red] (2.9,0.7) circle (0.2);
% % --------------------
% \draw[fill=black] (0.9,1.2) circle (0.2);
% \draw[fill=black] (2.4,1.2) circle (0.2);
% % --------------------
% \draw[fill=white] (0.9,1.2) circle (0.05);
% \draw[fill=white] (2.4,1.2) circle (0.05);
% % --------------------
% \draw[fill=black] (1,0.7) coordinate(B0) -- (2.3,0.7) coordinate(B1)
% .. controls (1.9,0.2) and (1.3,0.2) .. cycle;
% \draw[fill=white] (1,0.7) -- (2.3,0.7)
% .. controls (1.9,0.5) and (1.3,0.5) ..
% cycle;
% % --------------------
% \draw[fill=black] (OD) -- ++(-0.8,-0.7) -- +(-0.2,0.1) -- cycle;
% % --------------------
% \draw[fill=black] (OE) -- ++(0.6,-0.7) -- ++(0.2,0.1) -- cycle;
% % --------------------
%\end{scope}
% --------------------
% --------------------
\node [rotate=90] at (-0.5,2) {$y = 45$ m};
\draw[blue, -latex] (0.5,3) -- node[midway, right]{$\vec{g} = 10 \dfrac{\mathrm{m}}{\mathrm{s}^2}$} ++(0,-2);
% --------------------
\draw[red, -latex] (1,5) -- node[midway, above]{$\vec{V}_0 = 5 \dfrac{\mathrm{m}}{\mathrm{s}}$} ++(2,0);
\draw[-latex] (5.7,3.9) node[above]{$t = 3$ s} -- ++(-0.6,-1);
% --------------------
\end{tikzpicture}
每次尝试都被评论为在它们之间进行切换的简单方法。
Pokéball 的灵感来源于此画。
第一次尝试:
第二次尝试使用外部图片:
第三次尝试
ducks
:
答案2
碰巧有这个,可能有用。从这个网站上的很多答案中拼凑起来的!
\documentclass[17pt]{extarticle}
\usepackage[landscape,scale=.9]{geometry}
\thispagestyle{empty}
\pagestyle{empty}
\usepackage{multicol}
\usepackage{amsmath}
\usepackage{fontspec}
\usepackage{unicode-math}
\setmainfont{TeX Gyre Pagella}
\setmathfont{TeX Gyre Pagella Math}
\usepackage{tikz}
\usetikzlibrary{calc,angles}
\usetikzlibrary{decorations.pathmorphing}
\usepackage{tikzducks}
\newcommand\qline{\tikz[dashed] \draw (0,0) -- +(3,0);}
\let\vec=\mathbf
%\url{https://tex.stackexchange.com/a/74613/86}
\usepackage{charter}
\usetikzlibrary{hobby,
shapes.geometric,
decorations,
decorations.shapes,
shapes.geometric,
patterns
}
\makeatletter
\pgfdeclareradialshading[tikz@ball]{easter bg}{\pgfpoint{5bp}{25bp}}{%
color(0cm)=(tikz@ball!20);
color(0.15cm)=(tikz@ball!30);
color(0.4cm)=(tikz@ball!60);
color(0.9cm)=(tikz@ball)
}
\tikzoption{easter bg color}{\pgfutil@colorlet{tikz@ball}{#1}\def\tikz@shading{easter bg}\tikz@addmode{\tikz@mode@shadetrue}}
\pgfkeys{/tikz/easter star/.code args={#1 and #2}{
\pgfdeclareradialshading[tikz@ball]{easter star}{\pgfpoint{#1}{#2}}{%
color(0cm)=(tikz@ball!20);
color(0.3cm)=(tikz@ball!40);
color(0.65cm)=(tikz@ball!60);
color(1cm)=(tikz@ball)
}
}
\tikzoption{easter star color}{\pgfutil@colorlet{tikz@ball}{#1}\def\tikz@shading{easter star}\tikz@addmode{\tikz@mode@shadetrue}}
}
\makeatother
% original code by Paul Gaborit:
% tex.stackexchange.com/questions/72784/arrow-with-two-colors-with-tikz/#72793
\tikzset{
double path/.style args={#1 colored by #2 and #3}{
-,line join=round,line cap=rect,
shorten >=0.1cm,
shorten <=0.1cm,
line width=#1,#2, % first path
postaction={draw,-,#3,line width=(#1)/1.5,
shorten <=(#1)/3,shorten >=(#1)/3,
}, % second path
}
}
\tikzset{easter decoration 1/.style={
decorate,
decoration={
shape backgrounds,
shape=star,shape size=7pt,
shape sep={0.5cm, between center},
},
inner color=yellow,
outer color=yellow!50!orange,
draw=red!20!orange,
}
}
\pgfdeclarepatternformonly{fivepointed stars easter 2}{\pgfpointorigin}{\pgfpoint{10mm}{10mm}}{\pgfqpoint{10mm}{8mm}}%
{
\pgftransformshift{\pgfqpoint{1mm}{1mm}}
\pgfpathmoveto{\pgfqpointpolar{18}{1mm}}
\pgfpathlineto{\pgfqpointpolar{162}{1mm}}
\pgfpathlineto{\pgfqpointpolar{306}{1mm}}
\pgfpathlineto{\pgfqpointpolar{90}{1mm}}
\pgfpathlineto{\pgfqpointpolar{234}{1mm}}
\pgfpathclose%
\pgfusepath{fill}
}
\tikzset{easter decoration 3/.style={
draw=green!17!yellow,
line width=2pt,
star,
}
}
\pgfdeclarepatternformonly{fivepointed stars easter 3}{\pgfpointorigin}{\pgfpoint{12mm}{12mm}}{\pgfqpoint{12mm}{11mm}}%
{
\pgftransformshift{\pgfqpoint{1mm}{1mm}}
\pgfpathmoveto{\pgfqpointpolar{18}{1mm}}
\pgfpathlineto{\pgfqpointpolar{162}{1mm}}
\pgfpathlineto{\pgfqpointpolar{306}{1mm}}
\pgfpathlineto{\pgfqpointpolar{90}{1mm}}
\pgfpathlineto{\pgfqpointpolar{234}{1mm}}
\pgfpathclose%
\pgfusepath{fill}
}
% * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
\begin{document}
\begin{tikzpicture}[every node/.style={font=\large}]
\foreach[
evaluate=\k as \tint using {5*(5-\k)+50},
evaluate=\k as \xk using {\k/10}
] \k in {0,...,5} {
\draw[line width=2mm, green!\tint!brown, line cap=round, line join=round] (0,-3) ++(\xk,\xk) ++(-1,0) -- +(2,0);
}
\draw[line width=2mm, brown, line cap=round, line join=round] (0,-3) -- (0,0) ++(-.5,-.5) +(0,2) -- coordinate[pos=.25](a) +(0,0) -- (.5,.5) -- coordinate[pos=.75](b) +(0,2);
\foreach[
evaluate=\k as \tint using {-5*\k+50},
evaluate=\k as \xk using {\k/10}
] \k in {0,...,5} {
\draw[line width=2mm, green!\tint!brown, line cap=round, line join=round] (0,-3) ++(-\xk,-\xk) ++(-1,0) -- +(2,0);
}
\path (a) ++(-3,-2) coordinate(c);
\draw[line width=2mm, red!50!brown, line cap=round, line join=round] (b) -- (c);
\path (c) ++(2.1,-.4) coordinate (d);
\begin{scope}[shift=(d), xscale=-1]
\duck
\end{scope}
\begin{scope}[transform canvas={shift={(17,1.5)},scale=.3,rotate=30},use Hobby shortcut]
% \node[above,xshift=-3.5cm,yshift=-1.5cm] at (0.5,1){Easter Egg 3};
% path clipping
\clip[scale=-6]([closed=true]0.5,0.1) .. (0.775,0.35) .. (0.5,1) .. (0.225,0.35) .. (0.5,0.1);
% shading
\draw[easter bg color=green!77!blue,scale=-6,postaction={pattern=fivepointed stars easter 3,pattern color=green!20!yellow}]([closed=true]0.5,0.1) .. (0.775,0.35) .. (0.5,1) .. (0.225,0.35) .. (0.5,0.1);
\begin{scope}[transform canvas={shift={(-3.5,-3.5)}}]
\node[easter decoration 3,scale=2.25] at (0.55,0.65){};
\node[easter decoration 3,scale=1.5,rotate=10] at (1.45,1.45){};
\node[easter decoration 3,scale=1.5,rotate=-10] at (-0.5,1.95){};
\node[easter decoration 3,scale=1.65,rotate=-5] at (-0.75,-0.70){};
\node[easter decoration 3,scale=1.7,rotate=-3] at (0,-1.65){};
\node[easter decoration 3,scale=1.5,rotate=2] at (0.85,-0.65){};
\node[easter decoration 3,scale=1.75,rotate=14] at (2,0){};
\end{scope}
% draw again the border
\draw[scale=-6]([closed=true]0.5,0.1) .. (0.775,0.35) .. (0.5,1) .. (0.225,0.35) .. (0.5,0.1);
\end{scope}
\draw[dashed,->,line width=1mm] (-2,0) to[out=45,in=135] coordinate(m) (17,0);
\draw[line width=2mm, red!50!brown, line cap=round, line join=round] (a) -- (c);
\draw[line width=2mm, brown, line cap=round, line join=round] (-.5,-.5) -- +(0,2);
\draw[rounded corners=10mm, brown!50!black,
decorate,decoration={snake,amplitude=.1mm,segment length=10}]
(16,0) to[bend right,looseness=2] +(2,0);
\draw[|<->|,ultra thick] (7.5,0) -- node[right] {\(h\)} (m);
\draw[|<->|,ultra thick] (-2,-2) -- node[below] {\(l\)} (17,-2);
\draw[ultra thick] (1,0) coordinate (A) -- (-2,0) coordinate(B) -- +(45:3) coordinate(C);
\pic[draw, ultra thick, angle eccentricity=1.5,angle radius=1cm, pic text=\(\alpha\)] {angle};
\end{tikzpicture}
Initial speed \(u\) at angle \(\alpha\), acceleration \(-g\) vertically.
\begin{multicols}{2}
\begin{enumerate}
\item Initial velocity \(\vec{u} = \begin{pmatrix} \qline \\ \qline \end{pmatrix}\)
\item Vertical velocity \(v_y = \qline\)
\item Time to highest point \(t_m = \qline\)
\item Vertical position \(y = \qline\)
\item Height of highest point \(h = \qline\)
\item Time to landing \(t_l = \qline\)
\item Horizontal velocity \(v_x = \qline\)
\item Horizontal position \(x = \qline\)
\item Landing position \(l = \qline\)
\item Time in terms of horizontal position \(t = \qline\)
\item Vertical position in terms of horizontal position \(y = \qline\)
\end{enumerate}
\end{multicols}
\end{document}
答案3
这就是为什么鸭子很重要。
\documentclass{beamer}
\setbeamertemplate{navigation symbols}{}
\usepackage{tikz,tikzducks}
\usepackage{tikzlings}
\usepackage{textcomp}
\newcommand{\musicnotes}{\raisebox{-2pt}{\raisebox{4pt}{\textmusicalnote}%
\textmusicalnote\hspace{2pt}% https://tex.stackexchange.com/a/458440
\raisebox{4pt}{\textmusicalnote}}}
\usetikzlibrary{shapes.geometric,shapes.callouts,calc}
\newcommand\MarmotSays[2][]{\only<.(1)>{
\node[ellipse callout, draw,fill=white,align=center,text width=2.5cm,
anchor=south east,
callout absolute pointer={(0.41,0.35)},#1] at (0.35,0.5) {#2};
}}
\newcommand\CatSays[2][]{\only<.(1)>{
\node[ellipse callout, draw,fill=white,align=center,text width=2.5cm,
anchor=south west,
callout absolute pointer={(0.61,0.35)},#1] at (0.65,0.5) {#2};
}}
\begin{document}
\begin{frame}
\begin{tikzpicture}[overlay,remember picture]
\pgfmathsetseed{123}
\foreach \X in {1,...,42}
{\pgfmathsetmacro{\myx}{rnd}%
\pgfmathsetmacro{\myy}{rnd}%
\ifnum\X=1
\xdef\LstStars{(\myx,\myy)}%
\else
\xdef\LstStars{\LstStars,(\myx,\myy)}%
\fi}
\fill (current page.south west) rectangle (current page.north east);
\begin{scope}[shift={(current page.south west)},%
x={($(current page.south east)-(current page.south west)$)},
y={($(current page.north east)-(current page.south east)$)}]
\only<7->{\foreach \X in {1,...,84}
{\pgfmathsetmacro{\myscale}{0.4*(1+2*rnd)/3}
\duck[shift={(rnd,rnd)},xscale=0.069*\myscale,yscale=0.1*\myscale,body=gray]}}
\foreach \X in \LstStars
{\path \X node[star,fill=yellow,inner sep={2*(1+rnd)*1pt}] {};}
\fill[gray] ([yshift=2cm]current page.south west) to[bend left=8]
([yshift=2cm]current page.south east) |- (current page.south west);
\cat[shift={(0.6,0.2)},xscale=0.069,yscale=0.1,eyes=green]
\marmot[shift={(0.42,0.2)},xscale=0.069,yscale=0.1,teeth,whiskers]
\MarmotSays{\musicnotes}
\pause
\CatSays[node font=\large\bfseries]{MEOW!}
\pause
\MarmotSays{I think we can talk normal. Nobody is watching us.}
\pause
\CatSays{Think so, too.}
\pause
\MarmotSays{BTW, did you know that 80\%
of the matter of our universe is duck matter?}
\pause
\CatSays{Really? I always
thought it was \emph{dark} matter.}
\pause
\CatSays{OK OK, I see your point.}
\pause
\CatSays{There is indeed evidence for cold duck matter.}
\end{scope}
\end{tikzpicture}
\end{frame}
\end{document}