我想将 π 符号置于 π 数字螺旋的中心。我想知道是否可以更改 π 符号下数字的颜色?目前,数字是可见的,但我希望字体也能改变颜色。
\documentclass[tikz,border=5]{standalone}
\usetikzlibrary{decorations.text}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[
decoration={
reverse path,
text effects along path,
text={%
3{,}%
141592653589793238462643383279502884197169399375105820974944592307816406286208998628034 8253421170679%
821480865132823066470938446095505822317253594081284811174502841027019385211055596446229. 4895493038196%
442881097566593344612847564823378678316527120190914564856692346034861045432664821339360 7260249141273%
724587006606315588174881520920962829254091715364367892590360011330530548820466521384146 9519415116094%
330572703657595919530921861173819326117931051185480744623799627495673518857527248912279 3818301194912%
983367336244065664308602139494639522473719070217986094370277053921717629317675238467481 8467669405132%
000568127145263560827785771342757789609173637178721468440901224953430146549585371050792 2796892589235%
420199561121290219608640344181598136297747713099605187072113499999983729780499510597317 3281609631859%
502445945534690830264252230825334468503526193118817101000313783875288658753320838142061 7177669147303%
598253490428755468731159562863882353787593751957781857780532171226806613001927876611195 9092164201989%
380952572010654858632788659361533818279682303019520353018529689957736225994138912497217 7528347913151%
557485724245415069595082953311686172785588907509838175463746493931925506040092770167113 9009848824012%
858361603563707660104710181942955596198946767837449448255379774726847104047534646208046 6842590694912%
933136770289891521047521620569660240580381501935112533824300355876402474964732639141992 7260426992279%
678235478163600934172164121992458631503028618297455570674983850549458858692699569092721 0797509302955%
321165344987202755960236480665499119881834797753566369807426542527862551818417574672890 9777727938000%
816470600161452491921732172147723501414419735685481613611573525521334757418494684385233 2390739414333%
454776241686251898356948556209921922218427255025425688767179049460165346680498862723279 1786085784383%
827967976681454100953883786360950680064225125205117392984896084128488626945604241965285 0222106611863%
067442786220391949450471237137869609563643719172874677646575739624138908658326459958133 9047802759009%
946576407895126946839835259570982582262052248940772671947826848260147699090264013639443 7455305068203%
496252451749399651431429809190659250937221696461515709858387410597885959772975498930161 7539284681382%
686838689427741559918559252459539594310499725246808459872736446958486538367362226260991 2460805124388%
439045124413654976278079771569143599770012961608944169486855584840635342207222582848864 8158456028506%
016842739452267467678895252138522549954666727823986456596116354886230577456498035593634 5681743241125%
150760694794510965960940252288797108931456691368672287489405601015033086179286809208747 6091782493858%
900971490967598526136554978189312978482168299894872265880485756401427047755513237964145 1523746234364%
542858444795265867821051141354735739523113427166102135969536231442952484937187110145765 4035902799344%
037420073105785390621983874478084784896833214457138687519435064302184531910484810053706 1468067491927%
819119793995206141966342875444064374512371819217999839101591956181467514269123974894090 7186494231961%
},
text effects/.cd,
text along path,
character count=\i, character total=\n,
characters={scale=1-\i/\n}
}
]
\draw [decorate] (0,0)
\foreach \i [evaluate={\r=(\i/1800)^2;}] in {0,5,...,4000}{ -- (\i:\r)};
\filldraw[blue,opacity=0.7] (-3.32,1.88) .. controls (-2.62,4.28) and (0.04,2.87) .. (1.48,3.41) .. controls (1.38,2.54) and (0.57,2.53) .. (0.09,2.48) .. controls (0.08,1.03) and (-0.48,-1.4) .. (0.82,-0.31) .. controls (0.78,-1.24) and (-1.71,-2.57) .. (-0.31,2.51) .. controls (-0.87,2.5) and (-0.87,2.5) .. (-1.48,2.53) .. controls (-1.49,1.31) and (-2.05,-1.77) .. (-2.93,-1.1) .. controls (-3.48,-0.36) and (-2.27,-0.74) .. (-1.88,2.55) .. controls (-2.47,2.51) and (-2.79,2.36) .. (-3.32,1.88);
\end{tikzpicture}
\end{document}
如果有人知道创建圆周率数字的方法,而不是将它们复制粘贴到代码中,那就太好了,但我认为这只是一些 Python 代码的问题,所以我可能能够解决它。谢谢
答案1
只是做
\filldraw[blue, opacity=0.7] (-3.32,1.88) .. controls (-2.62,4.28) and (0.04,2.87) .. (1.48,3.41) .. controls (1.38,2.54) and (0.57,2.53) .. (0.09,2.48) .. controls (0.08,1.03) and (-0.48,-1.4) .. (0.82,-0.31) .. controls (0.78,-1.24) and (-1.71,-2.57) .. (-0.31,2.51) .. controls (-0.87,2.5) and (-0.87,2.5) .. (-1.48,2.53) .. controls (-1.49,1.31) and (-2.05,-1.77) .. (-2.93,-1.1) .. controls (-3.48,-0.36) and (-2.27,-0.74) .. (-1.88,2.55) .. controls (-2.47,2.51) and (-2.79,2.36) .. (-3.32,1.88);
\path (current bounding box.center);
\pgfgetlastxy\xxx\yyy
\typeout{\xxx, \yyy}
给我们
-28.45274pt, 24.32698pt
在日志文件中,这意味着圆周率符号的中心位于该坐标。只需将圆周率路径向相反方向移动,我们就会得到一条以 (0, 0) 为中心的路径。如果您不喜欢这样,则需要进行更多微调。
对于角色,我只是使用类似的风格手册中的例子:
characters={
scale=1-\i/\n,
text depth=+0pt,
text height=+.7em,
/utils/exec=\pgfmathparse{\i/\n*100},
text=red!\pgfmathresult!green
}
这将给你
我注释掉了一半以上的数字,因为路径不够长。剩余的字符不会添加到螺旋中,而且看起来不太好,因为缩放因子没有达到 0。
代码
\documentclass[tikz, border=5pt, convert]{standalone}
\usetikzlibrary{decorations.text}
\begin{document}
\begin{tikzpicture}[
decoration={
reverse path,
text effects along path,
text={%
3{,}%
1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679%
8214808651328230664709384460955058223172535940812848111745028410270193852110555964462294895493038196%
4428810975665933446128475648233786783165271201909145648566923460348610454326648213393607260249141273%
7245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094%
3305727036575959195309218611738193261179310511854807446237996274956735188575272489122793818301194912%
9833673362440656643086021394946395224737190702179860943702770539217176293176752384674818467669405132%
0005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235%
4201995611212902196086403441815981362977477130996051870721134999999837297804995105973173281609631859%
5024459455346908302642522308253344685035261931188171010003137838752886587533208381420617177669147303%
5982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989%
3809525720106548586327886593615338182796823030195203530185296899577362259941389124972177528347913151%
5574857242454150695950829533116861727855889075098381754637464939319255060400927701671139009848824012%
8583616035637076601047101819429555961989467678374494482553797747268471040475346462080466842590694912%
% 9331367702898915210475216205696602405803815019351125338243003558764024749647326391419927260426992279%
% 6782354781636009341721641219924586315030286182974555706749838505494588586926995690927210797509302955%
% 3211653449872027559602364806654991198818347977535663698074265425278625518184175746728909777727938000%
% 8164706001614524919217321721477235014144197356854816136115735255213347574184946843852332390739414333%
% 4547762416862518983569485562099219222184272550254256887671790494601653466804988627232791786085784383%
% 8279679766814541009538837863609506800642251252051173929848960841284886269456042419652850222106611863%
% 0674427862203919494504712371378696095636437191728746776465757396241389086583264599581339047802759009%
% 9465764078951269468398352595709825822620522489407726719478268482601476990902640136394437455305068203%
% 4962524517493996514314298091906592509372216964615157098583874105978859597729754989301617539284681382%
% 6868386894277415599185592524595395943104997252468084598727364469584865383673622262609912460805124388%
% 4390451244136549762780797715691435997700129616089441694868555848406353422072225828488648158456028506%
% 0168427394522674676788952521385225499546667278239864565961163548862305774564980355936345681743241125%
% 1507606947945109659609402522887971089314566913686722874894056010150330861792868092087476091782493858%
% 9009714909675985261365549781893129784821682998948722658804857564014270477555132379641451523746234364%
% 5428584447952658678210511413547357395231134271661021359695362314429524849371871101457654035902799344%
% 0374200731057853906219838744780847848968332144571386875194350643021845319104848100537061468067491927%
% 8191197939952061419663428754440643745123718192179998391015919561814675142691239748940907186494231961%
},
text effects/.cd,
text along path,
character count=\i, character total=\n,
characters={
scale/.expanded=1-\i/\n,
text depth=+0pt,
text height=+.7em,
/utils/exec=\pgfmathparse{\i/\n*100},
text=red!\pgfmathresult!green
}
}
]
\draw [decorate] (0,0)
\foreach \i [evaluate={\r=(\i/1800)^2;}] in {0,5,...,4000}{ -- (\i:\r)};
\filldraw[shift={(28.45274pt, -24.32698pt)}, blue, opacity=0.7]
(-3.32,1.88) .. controls (-2.62,4.28) and (0.04,2.87) .. (1.48,3.41)
.. controls (1.38,2.54) and (0.57,2.53) .. (0.09,2.48)
.. controls (0.08,1.03) and (-0.48,-1.4) .. (0.82,-0.31)
.. controls (0.78,-1.24) and (-1.71,-2.57) .. (-0.31,2.51)
.. controls (-0.87,2.5) and (-0.87,2.5) .. (-1.48,2.53)
.. controls (-1.49,1.31) and (-2.05,-1.77) .. (-2.93,-1.1)
.. controls (-3.48,-0.36) and (-2.27,-0.74).. (-1.88,2.55)
.. controls (-2.47,2.51) and (-2.79,2.36) .. (-3.32,1.88);
%\path (current bounding box.center);
%\pgfgetlastxy\xxx\yyy
%\typeout{\xxx, \yyy}
\end{tikzpicture}
\end{document}
答案2
从@Qrrbrbirlbel 的代码开始,我使用 来local bounding box
避免手动移动。bezier bounding box
来自bbox
提供更好的边界框。 - 只是偶然它们的中心接近。
\documentclass[tikz, border=1cm]{standalone}
\usetikzlibrary{decorations.text, bbox}
\begin{document}
\begin{tikzpicture}[
decoration={
reverse path,
text effects along path,
text={%
3{,}%
1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679%
8214808651328230664709384460955058223172535940812848111745028410270193852110555964462294895493038196%
4428810975665933446128475648233786783165271201909145648566923460348610454326648213393607260249141273%
7245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094%
3305727036575959195309218611738193261179310511854807446237996274956735188575272489122793818301194912%
9833673362440656643086021394946395224737190702179860943702770539217176293176752384674818467669405132%
0005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235%
4201995611212902196086403441815981362977477130996051870721134999999837297804995105973173281609631859%
5024459455346908302642522308253344685035261931188171010003137838752886587533208381420617177669147303%
5982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989%
3809525720106548586327886593615338182796823030195203530185296899577362259941389124972177528347913151%
5574857242454150695950829533116861727855889075098381754637464939319255060400927701671139009848824012%
8583616035637076601047101819429555961989467678374494482553797747268471040475346462080466842590694912%
},
text effects/.cd,
text along path,
character count=\i, character total=\n,
characters={
scale/.expanded=1-\i/\n,
text depth=+0pt,
text height=+.7em,
/utils/exec=\pgfmathparse{\i/\n*100},
text=red!\pgfmathresult!green
}}]
\pgfdeclarelayer{background}
\pgfdeclarelayer{foreground}
\pgfsetlayers{background, main, foreground}
\begin{scope}[local bounding box=pi, bezier bounding box]
\shade[top color=blue, bottom color=red, opacity=0.7, scale=1.4]
(-3.32,1.88) .. controls (-2.62,4.28) and (0.04,2.87) .. (1.48,3.41)
.. controls (1.38,2.54) and (0.57,2.53) .. (0.09,2.48)
.. controls (0.08,1.03) and (-0.48,-1.4) .. (0.82,-0.31)
.. controls (0.78,-1.24) and (-1.71,-2.57) .. (-0.31,2.51)
.. controls (-0.87,2.5) and (-0.87,2.5) .. (-1.48,2.53)
.. controls (-1.49,1.31) and (-2.05,-1.77) .. (-2.93,-1.1)
.. controls (-3.48,-0.36) and (-2.27,-0.74).. (-1.88,2.55)
.. controls (-2.47,2.51) and (-2.79,2.36) .. (-3.32,1.88);
\end{scope}
\begin{pgfonlayer}{background}
\draw[decorate, shift=(pi.center)] (0,0) \foreach \i [evaluate={\r=(\i/1800)^2;}] in {0,5,...,4000}{ -- (\i:\r)};
\end{pgfonlayer}
\end{tikzpicture}
\end{document}