考虑以下非常丑陋的 PSTricks 代码:
% latex file.tex
% dvips file.dvi
% ps2pdf file.ps
\documentclass{article}
\usepackage{pst-text,pst-slpe,pstricks-add}
\newcommand*\kurve{%
{\psset{linewidth = 2\pslinewidth}
\psline(12,4)(12,0.5)
\psarc(11.5,0.5){0.5}{270}{360}
\psline(11.5,0)(0.5,0)
\psarc(0.5,0.5){0.5}{180}{270}
\psline(0,0.5)(0,4)}}
\begin{document}
\begin{pspicture}(12,9)
\multido{\i = 0+15}{24}{%
\rput{\i}(2.5,6.5){\psline[linecolor = yellow](1.18,0)(2.5,0)}}
\psBall(2.5,6.5){yellow}{6ex}
\pstextpath[r](0,1ex){%
\psarc[linecolor = gray!70](6,33.39){30}{258.5}{281.5}}{Husholdningsfilm}
\pscustom[
linestyle = none,
fillstyle = solid,
fillcolor = blue!60
]{
\psplot[
algebraic,
plotpoints = 200
]{0}{12}{0.1*sin(10*x)+0.5}
\kurve
}
{\psset{linewidth = 2\pslinewidth}
\psline(0,0.5)(0,4)
\psline(12,4)(12,0.5)}
\pscustom[
fillstyle = solid,
fillcolor = white
]{
\psarc(7.8,0.2){0.2}{270}{360}
\psline(7.8,0)(4.2,0)
\psarc(4.2,0.2){0.2}{180}{270}
\psline(4,0.2)(4,1.5)(8,1.5)(8,0.2)
}
{\psset{
linewidth = 2\pslinewidth,
linecolor = white
}
\psline(4.012,1.5)(7.988,1.5)
\psline(4,0.2)(4.2,0)}
\psarc(4.2,0.2){0.2}{180}{270}
\psline(4,0.17)(4,0.23)
\psline(4.17,0)(4.23,0)
\psline[
linewidth = 2\pslinewidth,
linecolor = white
](7.8,0)(8,0.2)
\psarc(7.8,0.2){0.2}{270}{360}
\psline(8,0.17)(8,0.23)
\psline(7.77,0)(7.83,0)
\psframe[
fillstyle = solid,
fillcolor = gray!80
](5.5,3.395)(6.5,3.775)
\psarc(6,3.775){0.15}{0}{180}
\psframe[
fillstyle = solid,
fillcolor = gray!80
](5.2,0.02)(6.8,0.82)
\psarc[
linewidth = 1.5\pslinewidth
](6,0.8){0.25}{0}{180}
\kurve
\end{pspicture}
\end{document}
我有想要的输出但是代码很丑陋。
问题:我如何改进(即简化)代码?
答案1
要使文本沿曲线移动,请使用\pstextpath
命令pst-text
。以下是一段较短的代码:
\documentclass[x11names]{article}
\usepackage{pst-plot,pst-slpe, pst-text}
\usepackage{auto-pst-pdf} %
\newcommand*\suitcase[1][]{\psset{#1}%
\psframe[fillstyle=solid, fillcolor=gray!80](-0.8,0)(0.8,0.8)
\psarc[linewidth=1.5\pslinewidth](0,0.8){0.25}{0}{180}
}
\newcommand*\smallpot[1][]{%
\psset{linewidth = 2\pslinewidth, fillstyle=solid, fillcolor=white, #1}%
\pscustom{\psline[linearc=0.2](-2,1.5)(-2,0)(2,0)(2,1.5)}
}%
\newcommand*\mykurve[1][]{\psset{#1}\psline[linearc=0.5](0,4)(0,0)(12,0)(12,4)}
\begin{document}
\begin{pspicture}(12,9)
\psset{linejoin=1}
\multido{\i=0+15}{24}{%
\rput{\i}(2.5,6.5){\psline[linecolor = yellow](1.2,0)(2.5,0)}
}
\psBall(2.5,6.5){yellow}{8ex}
%
\pstextpath[r](0,-2.5ex){\psarc[linecolor = gray!70 ](6,33.39){30}{258.5}{281.5}}{Husholdningsfilm\quad}
\pscustom[linestyle=none, fillstyle=solid, fillcolor=blue!60]{%
\psplot[algebraic, plotpoints=200,plotstyle=curve]{12}{0}{0.1*sin(10*x)+0.5}
\mykurve
}%
\rput(6,0){\smallpot[linecolor=SteelBlue4]}
\rput(6,3.405){\psscalebox{0.625}{\suitcase}}%(6,3.3875)
\rput(6,\pslinewidth){\suitcase}
\mykurve[linewidth=2\pslinewidth, linecolor=SteelBlue4]
\end{pspicture}
\end{document}