我想使用 TikZ 来画一棵圣诞树。首先,我使用这个lindenmayersystems
库来画一棵树:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{lindenmayersystems}
\begin{document}
\begin{tikzpicture}
\draw [color=green!50!black, l-system={rule set={S -> [+++G][---G]TS,
G -> +H[-G]L, H -> -G[+H]L, T -> TL, L -> [-FFF][+FFF]F}, step=4pt, angle=18,
axiom=+++++SLFFF, order=11}] lindenmayer system -- cycle;
\end{tikzpicture}
\end{document}
我在 Peitgen 和 Saupe 的《分形图像的科学》中找到了这棵树。
谁能帮忙装饰一下?或者画一棵挂满圣诞装饰的树,比如金箔花环(lametta)、蜡烛、圣诞球、树顶装饰?或许给绿色加点阴影?
答案1
大家圣诞快乐!
有球、蜡烛和雪花的圣诞树
现在pic
非常有用。需要更新
代替
\newsavebox{\mycandle}
\savebox{\mycandle}{
\begin{tikzpicture}[scale=.1]
\shade[top color=yellow,bottom color=red] (0,0) .. controls (1,.2) and (1,.5) .. (0,2) .. controls (-1,.5) and (-1,.2) .. (0,0);
\fill[yellow!90!black] (.8,0) rectangle (-.8,-5);
\end{tikzpicture} }
\tikzset{ mycandle/.pic ...
代码
% !TEX TS-program = pdflatex
\documentclass[border=2mm]{standalone}
\usepackage[usenames,dvipsnames]{xcolor}
\usepackage{tikz}
\usetikzlibrary{ shapes,decorations.shapes,decorations.fractals,decorations.markings,shadows}
\tikzset{ mycandle/.pic={
\shade[top color=yellow,bottom color=red] (0,0) .. controls (1,.2) and (1,.5) .. (0,2) .. controls (-1,.5) and (-1,.2) .. (0,0);
\fill[yellow!90!black] (.8,0) rectangle (-.8,-5); }}
\tikzset{
paint/.style={draw=#1!50!black, fill=#1!50},
my star/.style={decorate,decoration={shape backgrounds,shape=star},star points=#1}}
\begin{document}
\begin{tikzpicture}[every pic/.style={scale=.1,transform shape} ,
ball red/.style={
decorate, decoration={ markings,mark=between positions .2 and 1 step 3cm
with
{ \pgfmathsetmacro{\sz}{2 + .5 * rand}
\path[shading=ball,ball color=red] (0,0) circle[radius=\sz mm]; }}},
ball blue/.style={decorate, decoration={ markings, mark=between positions 0.1 and .9 step 3cm
with {\pgfmathsetmacro{\sz}{2 + .5 * rand}
\path[shading=ball,ball color=blue] (0,0) circle[radius=\sz mm]; }}}]
\draw[fill=Maroon,ultra thick]
(.75,-1) .. controls (.5,.5) and (.5,3) .. (0.5,4)
-- (-0.5,4) .. controls (-.5,3) and (-.5,.5) .. (-.75,-1) ;
\draw[ultra thick,fill=green!50!black]
(0,10) .. controls (0,8) and (1,7) .. (1.5,7)
.. controls (1,7) and (1,7) .. (0.5,7.25)
.. controls (1.5,5) and (2.5,4) .. (3,4)
.. controls (2,4) and (1.25,4) .. (1,4.5)
.. controls (2,2) and (3.5,2) .. (4,2)
.. controls (1,1) and (-1,1) .. (-4,2)
.. controls (-3.5,2) and (-2,2) .. (-1,4.5)
.. controls (-1.25,4) and (-2,4) .. (-3,4)
.. controls (-2.5,4) and (-1.5,5) .. (-0.5,7.25)
.. controls (-1,7) and (-1,7) .. (-1.5,7)
.. controls (-1,7) and (0,8) .. (0,10)
;
\pic foreach \candle in {(2,5),(-2,5),(0.5,7.5),(-0.5,7.5),(-3,2.5), (3,2.5),
(1.5,1.75),(-1.5,1.75)} at \candle {mycandle} ;
\node [star, star point height=.5cm, minimum size=.5cm,draw,fill=yellow,thick]
at (0,10) {};
\begin{scope}[decoration={shape sep=.2cm, shape size=.25cm}]
\draw [my star=6, paint=red] (-4,2)
.. controls (0,2) and (1,3.5) .. (1,4.40);
\draw [my star=6, paint=red] (-1.5,5.40)
.. controls (0,5.40) and (0.5,6.5) .. (0.5,7);
\draw [my star=6, paint=blue] (4,2)
.. controls (0,2) and (-1,3.5) .. (-1,4.40);
\draw [my star=6, paint=blue] (1.5,5.40)
.. controls (0,5.40) and (-0.5,6.5) .. (-0.5,7);
\end{scope}
% the balls
\path[ball red]
(0,10) .. controls (0,8) and (1,7) .. (1.5,7)
.. controls (1,7) and (1,7) .. (0.5,7.25)
.. controls (1.5,5) and (2.5,4) .. (3,4)
.. controls (2,4) and (1.25,4) .. (1,4.5)
.. controls (2,2) and (3.5,2) .. (4,2)
.. controls (1,1) and (-1,1) .. (-4,2)
.. controls (-3.5,2) and (-2,2) .. (-1,4.5)
.. controls (-1.25,4) and (-2,4) .. (-3,4)
.. controls (-2.5,4) and (-1.5,5) .. (-0.5,7.25)
.. controls (-1,7) and (-1,7) .. (-1.5,7)
.. controls (-1,7) and (0,8) .. (0,10)
;
\path[ball blue]
(0,10) .. controls (0,8) and (1,7) .. (1.5,7)
.. controls (1,7) and (1,7) .. (0.5,7.25)
.. controls (1.5,5) and (2.5,4) .. (3,4)
.. controls (2,4) and (1.25,4) .. (1,4.5)
.. controls (2,2) and (3.5,2) .. (4,2)
.. controls (1,1) and (-1,1) .. (-4,2)
.. controls (-3.5,2) and (-2,2) .. (-1,4.5)
.. controls (-1.25,4) and (-2,4) .. (-3,4)
.. controls (-2.5,4) and (-1.5,5) .. (-0.5,7.25)
.. controls (-1,7) and (-1,7) .. (-1.5,7)
.. controls (-1,7) and (0,8) .. (0,10)
;
% the snow
\foreach \i in {0.5,0.6,...,1.6}
\fill [white!80!blue,decoration=Koch snowflake,opacity=.9]
[shift={(rand*5,rnd*8)},scale=\i]
[double copy shadow={opacity=0.2,shadow xshift=0pt,
shadow yshift=3*\i pt,fill=white,draw=none}]
decorate {
decorate {
decorate {
(0,0) -- ++(60:1) -- ++(-60:1) -- cycle
}
}
};
\end{tikzpicture}
\end{document}
答案2
如果图片后面的代码看不清楚,这里是完整的代码:
\documentclass{article}
\usepackage{listings}
\usepackage{tikz}
\usetikzlibrary{%
lindenmayersystems,
decorations.pathmorphing,
decorations.markings,
shapes.geometric,
calc%
}
\tikzset{
tinsel/.style={
#1,
rounded corners=10mm,
ultra thin,
decorate,
decoration={
snake,
amplitude=.1mm,
segment length=10,
}
},
baubles/.style={
decorate,
decoration={
markings,
mark=between positions .3 and 1 step 2cm
with
{
\pgfmathsetmacro{\brad}{2 + .5 * rand}
\path[shading=ball,ball color=#1] (0,0) circle[radius=\brad mm];
}
}
},
lights/.style={
decorate,
decoration={
markings,
mark=between positions 0 and 1 step 1cm
with
{
\pgfmathparse{rand > 0 ? "dart" : "kite"}
\let\lshape\pgfmathresult
\pgfmathsetmacro{\tint}{100*rnd}
\node[rotate=90,\lshape,shading=ball,inner sep=1pt,ball color=red!\tint!yellow] {};
}
}
}
}
\begin{document}
\begin{center}
\tikz[remember picture,overlay] \coordinate (star) at (0,-1);
\end{center}
\lstinputlisting[
breaklines=true,
language=TeX,
basicstyle=\tiny,
firstline=63,
lastline=103]{\jobname.tex}
\begin{tikzpicture}[overlay,remember picture]
\path (star) +(-50:7) coordinate (rhs) +(-130:7) coordinate (lhs);
\draw[brown!50!black,line width=5mm,line cap=round] (star) ++(-90:6.8) -- ++(0,-1) coordinate (base);
\node[scale=-1,trapezium,fill=black,minimum size=1cm] at (base) {};
\foreach \height/\colour in {%
.2/blue,
.4/yellow,
.6/red,
.8/orange,
1/pink%
} {
\draw[tinsel=\colour] ($(star)!\height!(lhs)$) to[bend right] ($(star)!\height!(rhs)$);
}
\path (star);
\pgfgetlastxy{\starx}{\stary}
\begin{scope}[xshift=\starx,yshift=\stary,yshift=-7cm]
\draw[color=green!50!black, l-system={rule set={S -> [+++G][---G]TS, G -> +H[-G]L, H -> -G[+H]L, T -> TL, L -> [-FFF][+FFF]F}, step=4pt, angle=18, axiom=+++++SLFFF, order=11}] lindenmayer system -- cycle;
\end{scope}
\foreach \height/\colour in {%
.1/pink,
.3/red,
.5/yellow,
.7/blue,
.9/orange%
} {
\draw[tinsel=\colour] ($(star)!\height!(lhs)$) to[bend right] ($(star)!\height!(rhs)$);
}
\foreach \height in {.15,.35,...,1} {
\draw[lights] ($(star)!\height!(lhs)$) to[bend right] ($(star)!\height!(rhs)$);
}
\foreach \angle/\colour in {
-50/red,
-70/yellow,
-90/blue,
-110/pink,
-130/purple%
} {
\draw[baubles=\colour] (star) -- ++(\angle:7);
}
\node[star,star point ratio=2.5,fill=yellow,minimum size=1cm] at (star) {};
\end{tikzpicture}
\end{document}
答案3
另一棵可以装饰的树:
祝大家圣诞快乐!
\documentclass[border=5mm]{standalone}
\usepackage{pgfplots}
\begin{document}
%
\begin{tikzpicture}
\begin{axis}[
hide axis, clip=false,
y domain=0:2*pi,
samples=30,axis equal, view={45}{20}]
\addplot3 [domain=0:4,surf,shader=flat,z buffer=sort,fill=green!50!brown, draw=green!50!black, line join=bevel]
({(1.3*x-floor(x))*x^0.5*cos(deg(y))},
{(1.3*x-floor(x))*x^0.5*sin(deg(y))},
{-5*x});
\addplot3 [domain=0:4.5, samples=10, samples y=0, fill=yellow!85!red, draw=yellow!55!red] ({0},{sin(x/5*360) * (1 - x + floor(x)) },{cos(x/5*360) * (1 - x + floor(x) ) + 0.5}) -- cycle;
\end{axis}
\end{tikzpicture}%
%
\end{document}
答案4
我一直很喜欢用直尺和圆规做东西(感谢绘制这个三角形的最简单方法是什么?),我想尝试用直尺和圆规制作一棵圣诞树。
(动画版本大约 5Mb。我必须将它粘贴到 imgur 以外的其他地方并链接到它。)
\documentclass[
% handout, % use this to see the final construction
xcolor=svgnames
]{beamer}
%\url{https://tex.stackexchange.com/q/142210/86}
%\url{https://tex.stackexchange.com/q/39149/86}
\usepackage{tikz}
\usetikzlibrary{decorations.text}
\usepackage[
% draft
]{rulercompass}
\setbeamertemplate{navigation symbols}{}
\setbeamercolor{background canvas}{bg=Beige}
\pgfdeclarelayer{picture}
\pgfdeclarelayer{points}
\pgfsetlayers{picture,main,points}
\begin{document}
\begin{frame}[plain]
\hfill%
\begin{tikzpicture}[
stop jumping,
max size={\textwidth}{\textheight},
pot/.style={
draw=brown,
on layer=picture,
ultra thick
},
trunk/.style={
draw=brown!50!black,
on layer=picture,
ultra thick
},
tree/.style={
draw=green!50!black,
on layer=picture,
ultra thick
},
bauble/.style={
fill=yellow,
ultra thick,
on layer=picture,
},
star/.style={
draw=yellow,
fill=red!50!black,
on layer=picture
},
ruler compass,
draft label/.style={
reset label anchor,
above,
font=\tiny
},
every segment/.style={
},
every compass/.style={
overlay,
},
every point/.style={
node on layer=points,
minimum size=1mm,
},
every arc/.style={
on layer=picture,
ultra thick
},
construction in use/.style={
draw=gray!50,
},
construction not in use/.style={
draw=gray!50,
},
]
\path (0,0) node[name=0,ruler compass/point=red];
\path (0,1) node[name=1,ruler compass/point=red];
\pause
\ruler<+->[ruler compass/ruler length=40]{0}{1}
\compass<+->{0}{1}
\point<.->{r-0-1}{c-0-1}{2}
\compass<+->{1}{a}
\point<.->{r-0-1}{c-1-a}{1}
\compass<+->{a}{1}
\point<.->{c-a-1}{c-1-a}{1}
\point<.->{c-a-1}{c-1-a}{2}
\compass<+->{b}{c}
\compass<+->{b}{a}
\point<.->{c-b-a}{r-0-1}{1}
\compass<+->{e}{b}
\point<.->{c-e-b}{c-b-a}{1}
\point<.->{c-e-b}{c-b-a}{2}
\point<.->{c-e-b}{r-0-1}{1}
\ruler<+->{c}{g}
\ruler<.->{d}{f}
\compass<+->{h}{g}
\compass<+->{a}{g}
\ruler<+->{c}{d}
\point<.->{r-c-d}{c-0-1}{1}
\point<.->{r-c-d}{c-0-1}{2}
\compass<+->{b}{1}
\point<.->{c-b-1}{r-0-1}{1}
\compass<+->{b}{0}
\point<.->{c-b-0}{r-0-1}{1}
\ruler<+->{f}{g}
\compass<+->{k}{l}
\point<.->{c-k-l}{r-f-g}{1}
\point<.->{c-k-l}{r-f-g}{2}
\ruler<+->{i}{m}
\ruler<+->{j}{n}
\point<.->{r-j-n}{c-h-g}{2}
\point<.->{r-i-m}{c-h-g}{2}
\point<.->{r-j-n}{c-a-g}{1}
\point<.->{r-i-m}{c-a-g}{1}
\compass<+->{q}{o}
\compass<.->{r}{p}
\point<.->{c-q-o}{r-j-n}{1}
\point<.->{c-r-p}{r-i-m}{1}
\draw<.->[pot] (g) arc[centred arc to={a}{q}]
(f) arc[arc flip,centred arc to={a}{r}];
\draw<.->[trunk] (o) -- (s) (p) -- (t);
\draw<.->[pot] (d) arc[centred arc to={b}{c}] -- (g) arc[arc flip,centred arc to={h}{f}] -- cycle;
\point<.->{c-h-g}{r-0-1}{1}
\compass<+->{u}{s}
\point<.->{c-u-s}{r-0-1}{1}
\compass<+->{v}{s}
\compass<+->{v}{u}
\point<.->{c-v-u}{r-0-1}{1}
\compass<+->{u}{w}
\compass<+->{w}{u}
\point<.->{c-u-w}{c-w-u}{1}
\point<.->{c-u-w}{c-w-u}{2}
\compass<+->{x}{v}
\compass<+->{y}{v}
\point<.->{c-x-v}{c-v-s}{2}
\point<.->{c-y-v}{c-v-s}{2}
\draw<.->[tree]
(v)
arc[centred arc to={x}{z}]
arc[arc flip,centred arc to={v}{aa}]
arc[centred arc to={y}{v}]
;
\compass<+->{v}{h}
\point<.->{c-v-h}{c-y-v}{2}
\point<.->{c-v-u}{c-y-v}{2}
\point<.->{c-v-u}{c-x-v}{2}
\point<.->{c-v-h}{c-x-v}{2}
\ruler<+->{ab}{ad}
\compass<+->{ab}{ad}
\compass<+->{ad}{ab}
\point<.->{c-ab-ad}{c-ad-ab}{1}
\compass<+->{af}{ab}
\point<.->{c-v-h}{r-i-m}{2}
\compass<+->{h}{ag}
\point<.->{c-v-h}{c-h-ag}{2}
\compass<+->{ag}{h}
\point<.->{c-v-h}{c-ag-h}{1}
\compass<+->{ai}{ag}
\point<.->{c-v-h}{c-ai-ag}{1}
\foreach[remember=\tpt as \ppt (initially i)] \tpt in {j,...,o}
{
\compass<+->{a\tpt}{a\ppt}
\point<.->{c-v-h}{c-a\tpt-a\ppt}{1}
}
\compass<+->{ah}{h}
\point<.->{c-v-h}{c-ah-h}{2}
\compass<+->{aq}{ah}
\point<.->{c-v-h}{c-aq-ah}{1}
\foreach[remember=\tpt as \ppt (initially q)] \tpt in {r,...,w}
{
\compass<+->{a\tpt}{a\ppt}
\point<.->{c-v-h}{c-a\tpt-a\ppt}{1}
}
\point<.->{c-v-u}{r-i-m}{2}
\compass<+->{u}{ay}
\compass<.->{ay}{u}
\point<.->{c-v-u}{c-ay-u}{1}
\compass<+->{az}{ay}
\point<.->{c-v-u}{c-az-ay}{1}
\point<.->{c-v-u}{c-u-ay}{2}
\compass<+->{bb}{u}
\point<.->{c-v-u}{c-bb-u}{2}
\compass<+->{bc}{bb}
\point<.->{c-v-u}{c-bc-bb}{1}
\compass<+->{bd}{bc}
\point<.->{c-bd-bc}{c-af-ab}{2}
\foreach[remember=\tpt as \ppt (initially d)] \tpt in {e,...,n}
{
\compass<+->{b\tpt}{b\ppt}
\point<.->{c-af-ab}{c-b\tpt-b\ppt}{2}
}
\foreach \bctr/\brad in {
h/ag,
aj/ai,
am/al,
ap/ao,
ar/aq,
au/at,
ax/aw,
ba/az,
u/ay,
bd/bc,
bg/bf,
bj/bi,
bm/bl%
}
{
\path<.->[bauble] (\bctr) to[circle through] (\brad);
}
\point<.->{c-ad-ab}{r-0-1}{1}
\compass<+->{v}{bp}
\compass<+->{bp}{v}
\point<.->{c-v-bp}{r-0-1}{2}
\compass<+->{bq}{v}
\point<.->{c-v-bp}{c-bp-v}{1}
\point<.->{c-v-bp}{c-bp-v}{2}
\point<.->{c-v-bp}{c-bq-v}{1}
\point<.->{c-v-bp}{c-bq-v}{2}
\fill<.->[star] (bp) -- (bu) -- (bt) -- cycle (bs) -- (br) -- (bq) -- cycle;
\compass<+->{b}{y}
{\huge
\path<+->[decorate,decoration={text along path,text align=center,text={Have a Constructive Christmas}}] (y) arc[arc flip,centred arc to={b}{x}];
}
\end{tikzpicture}%
\hspace*{\fill}%
\end{frame}
\end{document}
您还需要样式文件(另存为rulercompass.sty
),其中还包含了本网站上其他问题和答案中的很多内容:
\ProvidesPackage{rulercompass}
\usepackage{alphalph}
\usetikzlibrary{intersections,calc}
\newif\ifrc@draft
\newif\ifrc@beamer
\newif\ifrc@fliparc
\@ifclassloaded{beamer}{%
\rc@beamertrue
}{}
\DeclareOption{draft}{%
\rc@drafttrue
}
\DeclareOption{beamer}{%
\rc@beamertrue
}
\ProcessOptions
\newcounter{pointlabels}
\setcounter{pointlabels}{0}
\resetcounteronoverlays{pointlabels}
\ifrc@beamer
\tikzset{
onslide/.code args={<#1>#2}{%
\only<#1>{\pgfkeysalso{#2}}%
},
alt/.code args={<#1>#2#3}{%
\alt<#1>{\pgfkeysalso{#2}}{\pgfkeysalso{#3}}%
},
alt if exist/.code args={#1#2#3}{%
\@ifundefined{path@#1}{%
\pgfkeysalso{#2}%
}{
\alt<.-\csname path@#1\endcsname>{%
\pgfkeysalso{#2}%
}{
\pgfkeysalso{#3}%
}%
}%
},
intersection/save/.code={%
\begingroup
\only<.>{%
\tikz@intersect@path@names@parse#1\tikz@stop
\protected@write\pgfutil@auxout{}{%
\string\global\string\@namedef{path@\tikz@intersect@path@a}{\the\beamer@slideinframe}%
\string\global\string\@namedef{path@\tikz@intersect@path@b}{\the\beamer@slideinframe}%
}%
}%
\endgroup
}
}
\newcommand<>\compass[3][]{%
\draw#4[#1,ruler compass/compass={#2}{#3}];
}
\newcommand<>\ruler[3][]{%
\draw#4[#1,ruler compass/ruler={#2}{#3}];
}
\newcommand<>\point[4][]{%
\path#5 [name intersections={use=#2 and #3}] (intersection-#4) node[ruler compass/point,#1];
}
\else
\tikzset{
alt if exist/.code args={#1#2#3}{%
\pgfkeysalso{#2}%
},
onslide/.code args={<#1>#2}{%
\pgfkeysalso{#2}%
},
intersection/save/.code={%
\begingroup
\tikz@intersect@path@names@parse#1\tikz@stop
\protected@write\pgfutil@auxout{}{%
\string\global\string\@namedef{path@\tikz@intersect@path@a}{\the\beamer@slideinframe}%
\string\global\string\@namedef{path@\tikz@intersect@path@b}{\the\beamer@slideinframe}%
}%
\endgroup
}
}
\newcommand\compass[2]{%
\draw[ruler compass/compass={#1}{#2}];
}
\newcommand\ruler[2]{%
\draw[ruler compass/ruler={#1}{#2}];
}
\newcommand\point[4][]{%
\path [name intersections={use=#2 and #3}] (intersection-#4) node[ruler compass/point,#1];
}
\fi
\tikzset{
intersection/use/.style={%
of=#1,
save=#1,
},
circle through/.style={
to path={
\pgfextra{
\tikz@scan@one@point\pgfutil@firstofone(\tikztostart)\relax
\pgf@xa=\pgf@x
\pgf@ya=\pgf@y
\tikz@scan@one@point\pgfutil@firstofone(\tikztotarget)\relax
\pgfmathsetmacro\rc@radius{veclen(\pgf@x - \pgf@xa,\pgf@y - \pgf@ya)}%
}
circle[radius=\rc@radius pt] (\tikztotarget)
}
},
arc flip/.is if=
rc@fliparc,
centred arc to/.code 2 args={%
\tikz@scan@one@point\pgfutil@firstofone(#1)\relax
\pgfmathsetmacro\rc@radius{veclen(\tikz@lastx-\pgf@x,\tikz@lasty-\pgf@y)}%
\pgfmathsetmacro\rc@sangle{atan2(\tikz@lasty - \pgf@y,\tikz@lastx - \pgf@x)}%
\pgf@xa=\pgf@x
\pgf@ya=\pgf@y
\tikz@scan@one@point\pgfutil@firstofone(#2)\relax
\pgfmathsetmacro\rc@eangle{atan2(\pgf@y - \pgf@ya,\pgf@x - \pgf@xa)}%
\pgfmathsetmacro\rc@eangle{\rc@eangle < \rc@sangle ? \rc@eangle + 360 : \rc@eangle}%
\ifrc@fliparc
\pgfmathsetmacro\rc@eangle{\rc@eangle - 360}%
\fi
\pgfkeysalso{start angle=\rc@sangle, end angle=\rc@eangle, radius=\rc@radius pt}
},
ruler compass/.is family,
ruler compass/.cd,
construction in use/.style={
draw=blue
},
construction not in use/.style={
draw=gray!75,
},
compass/.style 2 args={
alt if exist={c-#1-#2}{
ruler compass/construction in use/.try,
}{
ruler compass/construction not in use/.try
},
name path=c-#1-#2,
ruler compass/every construction path/.try,
ruler compass/every compass/.try,
insert path={
(#1) to[circle through] (#2)
node[name=c-#1-#2-centre,ruler compass/aux point={#1}]
node[name=c-#1-#2-rim,ruler compass/aux point={#2}]
},
},
ruler/.style 2 args={
overlay,
alt if exist={r-#1-#2}{
ruler compass/construction in use/.try
}{
ruler compass/construction not in use/.try
},
name path=r-#1-#2,
ruler compass/every construction path/.try,
ruler compass/every ruler/.try,
insert path={
($(#1)!\pgfkeysvalueof{/tikz/ruler compass/ruler length}!(#2)$) -- ($(#2)!\pgfkeysvalueof{/tikz/ruler compass/ruler length}!(#1)$)
node[name=r-#1-#2-start,ruler compass/aux point={#1}]
node[name=r-#1-#2-end,ruler compass/aux point={#2}]
},
},
ruler length/.initial=20,
aux point/.style={
circle,
minimum width=4mm,
onslide=<.|handout:0>{draw=red},
node contents={},
at={(#1)},
ruler compass/every aux point/.try
},
point/.style={
ruler compass/name it,
coordinate,
node contents={},
ruler compass/every point/.try,
insert path={
node[
fill=#1,
circle,
minimum width=1mm,
inner sep=0mm,
reset label anchor,
anchor=center,
node contents={}
]
}
},
name it/.code={%
\ifx\tikz@fig@name\pgfutil@empty
\stepcounter{pointlabels}%
\pgfkeysalso{name=\alphalph{\value{pointlabels}}}%
\ifrc@draft
\pgfkeysalso{label={[ruler compass/draft label/.try]\alphalph{\value{pointlabels}}}}%
\fi
\fi
},
point/.default=black,
}
\newcounter{jumping}
\resetcounteronoverlays{jumping}
\def\rc@scale{1}
\def\jump@setbb#1#2#3{%
\@ifundefined{jump@#1@maxbb}{%
\expandafter\gdef\csname jump@#1@maxbb\endcsname{#3}%
}{%
\csname jump@#1@maxbb\endcsname
\pgf@xa=\pgf@x
\pgf@ya=\pgf@y
#3
\pgfmathsetlength\pgf@x{max(\pgf@x,\pgf@xa)}%
\pgfmathsetlength\pgf@y{max(\pgf@y,\pgf@ya)}%
\expandafter\xdef\csname jump@#1@maxbb\endcsname{\noexpand\pgfpoint{\the\pgf@x}{\the\pgf@y}}%
}
\@ifundefined{jump@#1@minbb}{%
\expandafter\gdef\csname jump@#1@minbb\endcsname{#2}%
}{%
\csname jump@#1@minbb\endcsname
\pgf@xa=\pgf@x
\pgf@ya=\pgf@y
#2
\pgfmathsetlength\pgf@x{min(\pgf@x,\pgf@xa)}%
\pgfmathsetlength\pgf@y{min(\pgf@y,\pgf@ya)}%
\expandafter\xdef\csname jump@#1@minbb\endcsname{\noexpand\pgfpoint{\the\pgf@x}{\the\pgf@y}}%
}
}
\tikzset{
stop jumping/.style={
execute at end picture={%
\stepcounter{jumping}%
\pgfmathsetlength\pgf@xa{\pgf@picminx/\rc@scale}%
\pgfmathsetlength\pgf@ya{\pgf@picminy/\rc@scale}%
\pgfmathsetlength\pgf@xb{\pgf@picmaxx/\rc@scale}%
\pgfmathsetlength\pgf@yb{\pgf@picmaxy/\rc@scale}%
\immediate\write\pgfutil@auxout{%
\noexpand\jump@setbb{\the\value{jumping}}{\noexpand\pgfpoint{\the\pgf@xa}{\the\pgf@ya}}{\noexpand\pgfpoint{\the\pgf@xb}{\the\pgf@yb}}
},
\csname jump@\the\value{jumping}@maxbb\endcsname
\path (\the\pgf@x,\the\pgf@y);
\csname jump@\the\value{jumping}@minbb\endcsname
\path (\the\pgf@x,\the\pgf@y);
},
},
max size/.code 2 args={%
\addtocounter{jumping}{1}%
\pgfutil@ifundefined{jump@\the\value{jumping}@maxbb}{}{%
\csname jump@\the\value{jumping}@maxbb\endcsname
\pgf@xa=\pgf@x
\pgf@ya=\pgf@y
\csname jump@\the\value{jumping}@minbb\endcsname
\advance\pgf@xa by -\pgf@x
\advance\pgf@ya by -\pgf@y
\pgfmathsetmacro\rc@xratio{\pgf@xa > #1 ? \pgf@xa/#1 : 1}%
\pgfmathsetmacro\rc@yratio{\pgf@ya > #2 ? \pgf@ya/#2 : 1}%
\pgfmathsetmacro\rc@scale{1/max(\rc@xratio,\rc@yratio)}%
\pgfkeysalso{scale=\rc@scale}%
}
\addtocounter{jumping}{-1}%
}
}
\tikzset{
on layer/.code={
\pgfonlayer{#1}\begingroup
\aftergroup\endpgfonlayer
\aftergroup\endgroup
},
node on layer/.code={
\gdef\node@@on@layer{%
\setbox\tikz@tempbox=\hbox\bgroup\pgfonlayer{#1}\unhbox\tikz@tempbox\endpgfonlayer\egroup}
\aftergroup\node@on@layer
},
reset label anchor/.code={%
\let\tikz@auto@anchor=\pgfutil@empty
\def\tikz@anchor{#1}
},
reset label anchor/.default=center
}
\def\node@on@layer{\aftergroup\node@@on@layer}
\endinput