You do not have permission to delete messages in this group
Copy link
Report message
Sign in to report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to
In simple drawing programs I keep running into the very minor
problem that you have to call 'moveto' on the first point but
then 'lineto' on all the other points to put a line segment into
the path. It is very minor. But it keeps on happening.
This last time around I had my points all nicely packed into
an array of array. Lovely. And that led to this function which
I haven't found the right name for:
/fx,mapgxs { % a f g . [a0 f] [a1 g .. aN g]
3 1 roll exch dup first % g f a a0
3 -1 roll [ 3 1 roll exec ] % g a [a0 f]
3 1 roll rest exch map % [a0 f] [a1 g .. aN g]
} def
/first{ 0 get } def
/rest{ 1 1 index length 1 sub getinterval } def
/map { 1 index xcheck 3 1 roll [ 3 1 roll forall ] exch {cvx} if } def
Which you call like this:
/draw { % [[x0 y0]..[xN yN]] . -
{aload pop moveto} {aload pop lineto} fx,mapgxs pop pop
closepath
} def
Looking over some old code just now I found a completely
different approach to the same problem, by redefining the
thing to call. The `currentpoint stroke moveto` is just to "animate"
the drawing.