我正在尝试在 PostScript 中为我的 LOGO 程序找到等效代码:
PROC FRACTAL( SIZE )
IF SIZE < 1 THEN
FORWARD 5
ELSE
LEFT 90
RIGHT 90
RIGHT 90
RIGHT 90
RIGHT 90
RIGHT 90
FORWARD 60
ENDIF
PROC MAIN( VOID )
FRACTAL( 5 )
到目前为止我得到了
%!
%(debug.ps/db5.ps)run traceon stepon currentfile cvx debug
/Xpos { 300 } def
/Ypos { 500 } def
/Heading { 0 } def
/Arg { 0 } def
/RIGHT {
Heading exch add Trueheading
/Heading exch store
} def
/LEFT {
Heading exch sub Trueheading
/Heading exch store
} def
/Trueheading {
360 mod dup
0 lt { 360 add } if
} def
/FORWARD {
dup Heading sin mul
exch Heading cos mul
2 copy Newposition
rlineto
} def
/Newposition {
Heading 180 gt Heading 360 lt
and { neg } if exch
Heading 90 gt Heading 270 lt
and { neg } if exch
Ypos add /Ypos exch def
Xpos add /Xpos exch def
} def
/SIZE { 5 } def
/FRACTAL{
1 dict begin
/SIZE exch def
SIZE
1
lt
{
5
FORWARD
}{
90
LEFT
90
RIGHT
90
RIGHT
90
RIGHT
90
RIGHT
90
RIGHT
60
FORWARD
} ifelse
end
} def
/MAIN{
5
FRACTAL
} def
Xpos Ypos moveto
MAIN
stroke
showpage
该解决方案基于此问题:Logo to PostScript mini-Compiler
这段代码对我来说看起来不错,但是出于某种原因 PS 不想显示图片。