![调整字体大小以达到假透视效果](https://linux22.com/image/259194/%E8%B0%83%E6%95%B4%E5%AD%97%E4%BD%93%E5%A4%A7%E5%B0%8F%E4%BB%A5%E8%BE%BE%E5%88%B0%E5%81%87%E9%80%8F%E8%A7%86%E6%95%88%E6%9E%9C.png)
我想在左侧的路径上添加文本,字体大小从到连续调整,\Huge
以实现\tiny
类似透视的效果。字体大小步骤不应该是\Huge
、、、…… ,但字体大小也应该取列出的大小之间的值。\huge
\LARGE
\tiny
我想实现这样的目标:
并将其放在第一个图形的路径上。
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
\usetikzlibrary{decorations.text}
\usepackage[active,tightpage]{preview}
\PreviewEnvironment{tikzpicture}
\begin{document}
\begin{tikzpicture}[y=0.80pt,x=0.80pt,yscale=-1, inner sep=0pt, outer sep=0pt]
% BOTTOM_1
\path [decorate,%
decoration={text along path,%
text={|\tiny|~~Lorem ipsum dolor sit amet, dona abstulit meis~||},%
text align={fit to path stretching spaces}}]
(373.7500, 406.2500) -- (586.2500, 406.2500);
% BOTTOM_2
\path [decorate,%
decoration={text along path,%
text={|\scriptsize|~~commendet' permansit in. Adhibitis amor est~||},%
text align={fit to path stretching spaces}}]
(366.6667,413.3333) -- (593.3333,413.3333);
% BOTTOM_3
\path [decorate,%
decoration={text along path,%
text={|\footnotesize|~amet constanter determinatio debitis torporis~||},%
text align={fit to path stretching spaces}}]
(358.5714,421.4286) -- (601.4286,421.4286);
% BOTTOM_4
\path [decorate,%
decoration={text along path,%
text={|\small|~quin. Suam ad quia ei quoque sed dominum oculo~||},%
text align={fit to path stretching spaces}}]
(349.2308,430.7692) -- (610.7692,430.7692);
% BOTTOM_5
\path [decorate,%
decoration={text along path,%
text={|\normalsize|~capillos quam aniculae morsque nutricem valeas~||},%
text align={fit to path stretching spaces}}]
(338.3333,441.6667) -- (621.6667,441.6667);
% BOTTOM_6
\path [decorate,%
decoration={text along path,%
text={|\large|~Apollonium contigit cum. Taliarchum in modo~||},%
text align={fit to path stretching spaces}}]
(325.4545,454.5455) -- (634.5454,454.5455);
% BOTTOM_7
\path [decorate,%
decoration={text along path,%
text={|\Large|~invenit iuvenem patre ad quia illum ille~||},%
text align={fit to path stretching spaces}}]
(310.0000,470.0000) -- (650.0000,470.0000);
% BOTTOM_8
\path [decorate,%
decoration={text along path,%
text={|\LARGE|~illum decidat quam dicentes multa prima~||},%
text align={fit to path stretching spaces}}]
(291.1111,488.8889) -- (668.8889,488.8889);
% BOTTOM_9
\path [decorate,%
decoration={text along path,%
text={|\huge|~donatoris substantiae. Esse deprecor~||},%
text align={fit to path stretching spaces}}]
(267.5000,512.5000) -- (692.6609,512.5000);
% BOTTOM_10
\path [decorate,%
decoration={text along path,%
text={|\Huge|~cum magna Dianam Interposito eum.||},%
text align={fit to path stretching spaces}}]
(237.1429,542.8571) -- (722.8571,542.8571);
% LEFT_6
\path[draw, cm={{0.55521796,0.0,0.0,0.55521796,(-142.0,95.56731)}}]
(682.8721,280.7209) -- (940.1713,332.1807);
% LEFT_5
\path[draw, cm={{0.55521796,0.0,0.0,0.55521796,(-142.0,95.56731)}}]
(682.8721,368.2026) -- (940.1713,368.2026);
% LEFT_4
\path[draw, cm={{0.55521796,0.0,0.0,0.55521796,(-142.0,95.56731)}}]
(682.8721,455.6843) -- (940.1713,404.2245);
% LEFT_3
\path[draw, cm={{0.55521796,0.0,0.0,0.55521796,(-142.0,95.56731)}}]
(682.8721,543.1661) -- (940.1713,440.2464);
% LEFT_2
\path[draw, cm={{0.55521796,0.0,0.0,0.55521796,(-142.0,95.56731)}}]
(682.8721,630.6478) -- (940.1713,476.2683);
% LEFT_1
\path[draw, cm={{0.55521796,0.0,0.0,0.55521796,(-142.0,95.56731)}}]
(682.8721,718.1295) -- (940.1713,512.2902);
% BOTTOM_LEFT
\path[draw, cm={{0.55521796,0.0,0.0,0.55521796,(-142.0,95.56731)}}]
(682.8721,805.6112) -- (940.1713,548.3120);
% BOTTOM_RIGHT
\path[draw, cm={{0.55521796,0.0,0.0,0.55521796,(-142.0,95.56731)}}]
(1300.3902,548.3120) -- (1557.6894,805.6112);
% path3109
\path[cm={{0.55521796,0.0,0.0,0.55521796,(-142.0,95.56731)}},draw=black,line
join=miter,line cap=butt,line width=0.800pt] (682.8721,805.6112) --
(682.8721,280.7209);
% path3111
\path[cm={{0.55521796,0.0,0.0,0.55521796,(-142.0,95.56731)}},draw=black,line
join=miter,line cap=butt,line width=0.800pt] (940.1713,332.1807) --
(940.1713,548.3120);
% path3113
\path[cm={{0.55521796,0.0,0.0,0.55521796,(-142.0,95.56731)}},draw=black,line
join=miter,line cap=butt,line width=0.800pt] (940.1713,548.3120) --
(1300.3902,548.3120);
% path3126
\path[cm={{0.55521796,0.0,0.0,0.55521796,(-142.0,95.56731)}},draw=black,line
join=miter,line cap=butt,line width=0.800pt] (940.1713,332.1807) --
(1300.3902,548.3120);
% path3902
\path[cm={{0.55521796,0.0,0.0,0.55521796,(-142.0,95.56731)}},draw=black,fill=black]
(940.9426,440.5375) -- (940.9426,333.5818) -- (941.8770,334.0818) .. controls
(943.1031,334.7380) and (1296.8461,547.1006) .. (1297.0831,547.3227) ..
controls (1297.1831,547.4165) and (1217.0924,547.4932) .. (1119.1038,547.4932)
-- (940.9426,547.4932) -- (940.9426,440.5375) -- cycle;
\end{tikzpicture}
\end{document}
编辑#1
使用\foreach
TikZ,我成功地获得了一个角色几乎所需的效果。
\newcommand\myfontsize[1]{\fontsize{#1}{10}\selectfont}
\begin{tikzpicture}
\foreach \x in {22.82086,...,6.80565}
{
\draw (-\x, 0) node {\myfontsize{\x}a};
}
\end{tikzpicture}
但我仍然不知道如何将其应用于一系列字符(例如一个句子),并将文本放在路径上。
编辑#2
进一步阅读 TikZ 手册后,我发现我可以同时迭代两个变量。这允许我在迭代中为每个字符使用不同的字体大小。
\begin{tikzpicture}
\foreach \i/\char in {22.82086/a,18.8170575/b,14.813255/c,10.8094525/d,6.80565/e}
{
\draw (-\i, 0) node {\myfontsize{\i}\char};
}
\end{tikzpicture}
但是我必须在\foreach
循环中明确指定步长。因此,这引发了一个问题:如何根据要打印的字符数计算步长。
答案1
我在这个问题上找到了问题的答案使用 TikZ 制作螺旋状文本。所有荣誉都归于原始答案。
包含以下宏后,您可以在装饰选项中使用text path start scale=2.4
和text path end scale=0.5
键值对。
\makeatletter
\let\pgf@lib@dec@text@dobox@original=\pgf@lib@dec@text@dobox%
\def\pgf@lib@dec@text@dobox{%
\pgf@lib@dec@text@dobox@original%
\ifpgfdecorationtextalongpathscaletext%
\pgfmathparse{\pgf@lib@dec@text@endscale+(\pgf@lib@dec@text@startscale-\pgf@lib@dec@text@endscale)*\pgfdecoratedremainingdistance/\pgfdecoratedpathlength}%
\setbox\pgf@lib@dec@text@box=\hbox{\scalebox{\pgfmathresult}{\box\pgf@lib@dec@text@box}}%
\fi%
}
\newif\ifpgfdecorationtextalongpathscaletext
\def\pgf@lib@dec@text@startscale{1}
\def\pgf@lib@dec@text@endscale{1}
\pgfkeys{/pgf/decoration/.cd,
text path start scale/.code={%
\pgfdecorationtextalongpathscaletexttrue%
\def\pgf@lib@dec@text@startscale{#1}%
},
text path end scale/.code={%
\pgfdecorationtextalongpathscaletexttrue%
\def\pgf@lib@dec@text@endscale{#1}%
}
}
请参阅LEFT_1
问题中的路径并将其替换为以下内容:
% LEFT_1
\path[decorate,%
decoration={text along path,%
text path start scale=2.4,
text path end scale=0.5,
text={vso nbl dsfn klijvb sodvn},%
text align={fit to path stretching spaces}},%
cm={{0.55521796,0.0,0.0,0.55521796,(-142.0,95.56731)}}]
(682.8721,718.1295) -- (940.1713,512.2902);
输出将是: