I'm trying to use pathforall to apply a different color to each line drawn in a path. When i put "stroke" at the end, it obviously only draws the shape in most recent color. How can i execute a stroke after each color change? The function block of /lineto doesnt accept "stroke" in it. Here's my code:
/Arial 12 selectfont
/color 6 def
/s 20 string def
1 setlinewidth
/#NextColor{
color 10 gt
{
0
/color exch def
}
{
color 4 add
/color exch def
color 8 div color 15 div color 19 div setrgbcolor
color 8 div s cvs show
( ) show
}
ifelse
} def
300 300 translate
-72 -72 moveto 72 -72 lineto 72 72 lineto -72 72 lineto -72 -72 lineto -100 -100 lineto 100 -100 lineto 100 100 lineto -100 100 lineto -100 -100 lineto
{/moveto load}
{/lineto load #NextColor }
{/curveto load}
{/closepath load}
pathforall
stroke