从段落流出的螺旋状文本

从段落流出的螺旋状文本

曾经有一个号码关于如何创建文本螺旋的问题。

我一直试图更进一步,让螺旋从段落自然结束的地方开始。

假设我们有一个段落:

Lorem ipsum dolor sit amet,consectetur adipiscing elit。玛利亚出现了,他用石头砸自己的脚,然后把石头砸碎了,然后把尸体放回原处。

sedaugue螺旋上的前两个点。从那里开始,段落的流程将平滑地过渡到螺旋的曲线,该曲线位于页面的中间(如上面的链接所示)。

有办法实现这个吗?我修改链接中的代码没有取得多大成功。特别是,我不知道如何从段落结束的地方开始螺旋,并让最后几个单词自然地弯曲到螺旋中。

答案1

这个问题(以及答案)存在一些问题。最重要的一点是,你需要确保螺旋的“起点”不在直线的开头或结尾附近。但是,有了这一警告并依靠你链接的巧妙答案,你可以这样做:

\documentclass[12pt]{article}
\usepackage{tikz}
\usetikzlibrary{decorations.text}

\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}%
    }
}

\makeatother

% \spiralit:
% #1 = rotation correction; default 95°
% #2 = manual horizontal space correction
% #3 = text scaling start point (should be "1" in this context!)
% #4 = text scaling end point
% #5 = text to spiral
\newcommand{\spiralit}[5][95]{%
  \hspace*{#2}%
  \raisebox{-\height}{%
    \tikz [decoration={
      reverse path,
      text along path,
      text path start scale=#3,
      text path end scale=#4,
      text={{#5}}}]
    \path [draw, decorate, rotate=#1]
    (0,0)
   \foreach \i [evaluate={\r=(\i/2000)^2;}] in {0,5,...,2880}{ -- (\i:\r)};
}}

\begin{document}

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent mauris massa, placerat sit amet scelerisque ac, auctor sed augue:
\spiralit{-1.6cm}{1}{0.5}{Is there a way to accomplish this? I've not
  had much success modifying the code in the link. In particular, I'm
  having trouble with how to begin the spiral from where the paragraph
  leaves off}

\bigskip

% Compare the explicit version: with different `end scale`, only 90°, and (consequently) different \hspace...
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent mauris massa, placerat sit amet scelerisque ac, auctor sed augue:
\hspace*{-1.75cm}%
{\raisebox{-\height}{\tikz [
decoration={
    reverse path,
    text along path,
    text path start scale=1,
    text path end scale=0.25,
    text={Is there a way to accomplish this? I've not had much success modifying the code in the link. In particular, I'm having trouble with how to begin the spiral from where the paragraph leaves off, and having the last few words curve naturally into it.}}]
  \path [draw, decorate, rotate=90]
  (0,0)
    \foreach \i [evaluate={\r=(\i/2000)^2;}] in {0,5,...,2880}{ -- (\i:\r)};
}}

\end{document}

tikz-螺旋

相关内容