
我想在 Ti 中顯示文本kZ 是透視扭曲的,如下圖:
TeX.SE 上有許多類似的解決方案(這裡,這裡, 或者這裡),但我發現的所有這些都只是通過使用傾斜和傾斜來偽造透視。
解決方案應將文字轉換為:
- 有一個水平消失點,所有通常水平平行的線都明顯會聚集到該消失點
- 有一個垂直消失點,所有通常垂直平行的線都會匯聚到該點或保持它們嚴格平行(就像上面的範例一樣)
- 如果您的解決方案允許使用者明確定義消失點,那就太好了。
您可以將此作為起點:
\documentclass[tikz]{standalone}
\begin{document}
\begin{tikzpicture}
\node[draw,align=left] at (0,0) {some text\\maybe with line breaks};
\end{tikzpicture}
\end{document}
答案1
這種方法將單字分成小三角形,並對每個三角形施加傾斜和傾斜。這適用於投影以及一般的非線性變換。
之前已經出現過
\documentclass[border=9,tikz]{standalone}
\begin{document}
\fontsize{188pt}{0}\bfseries
\pgfmathdeclarefunction{fxx}{2}{\pgfmathparse{fx(#1+1,#2)-fx(#1,#2)}}
\pgfmathdeclarefunction{fxy}{2}{\pgfmathparse{fy(#1+1,#2)-fy(#1,#2)}}
\pgfmathdeclarefunction{fyx}{2}{\pgfmathparse{fx(#1,#2+1)-fx(#1,#2)}}
\pgfmathdeclarefunction{fyy}{2}{\pgfmathparse{fy(#1,#2+1)-fy(#1,#2)}}
\begin{tikzpicture}
\pgfmathdeclarefunction{gx}{2}{\pgfmathparse{3*#1-20}}
\pgfmathdeclarefunction{gy}{2}{\pgfmathparse{3.1622*#2}}
\pgfmathdeclarefunction{gz}{2}{\pgfmathparse{#1+10}}
\pgfmathdeclarefunction{fx}{2}{\pgfmathparse{gx(#1,#2)*6/gz(#1,#2)}}
\pgfmathdeclarefunction{fy}{2}{\pgfmathparse{gy(#1,#2)*6/gz(#1,#2)}}
\clip(-15,-9)rectangle(15,10);
\foreach\i in{0,...,40}{
\foreach\j in{-3,...,3}{
\pgfmathsetmacro\aa{fxx(\i,\j)}
\pgfmathsetmacro\ab{fxy(\i,\j)}
\pgfmathsetmacro\ba{fyx(\i,\j)}
\pgfmathsetmacro\bb{fyy(\i,\j)}
\pgfmathsetmacro\xx{fx (\i,\j)}
\pgfmathsetmacro\yy{fy (\i,\j)}
\pgflowlevelobj{
\pgfsettransformentries{\aa}{\ab}{\ba}{\bb}{\xx cm}{\yy cm}
}{
\clip(1,0)--(0,0)--(0,1)--cycle;
\draw(1,0)--(0,0)--(0,1)--cycle;
\tikzset{shift={(-\i,-\j)}}
\path(20,.5)node{WORDART};
}
\pgfmathsetmacro\aa{fxx(\i ,\j+1)}
\pgfmathsetmacro\ab{fxy(\i ,\j+1)}
\pgfmathsetmacro\ba{fyx(\i+1,\j )}
\pgfmathsetmacro\bb{fyy(\i+1,\j )}
\pgfmathsetmacro\xx{fx (\i+1,\j+1)}
\pgfmathsetmacro\yy{fy (\i+1,\j+1)}
\pgflowlevelobj{
\pgfsettransformentries{\aa}{\ab}{\ba}{\bb}{\xx cm}{\yy cm}
}{
\clip(0,0)--(-1,0)--(0,-1)--cycle;
\draw(0,0)--(-1,0)--(0,-1)--cycle;
\tikzset{shift={(-\i-1,-\j-1)}}
\path(20,.5)node{WORDART};
}
}
}
\end{tikzpicture}
\end{document}