On 10/5/2013 5:52 PM, Peter Rolf wrote:
I played around with it, but I have problems to understand the format of the returned path.
Example: % -------- \setuppagenumber[state=stop]
\starttext \nopdfcompression
\startMPpage path p; p:= (20,20){up} .. {down}(200,100); passvariable("path",p); draw p ; \stopMPpage
\ctxlua{inspect{metapost.variables["path"]}} \stoptext % -------
The PDF code of the path is (mainly)
20.000000 20.000000 m 20.000000 190.342880 200.000000 184.016693 200.000000 100.000000 c
"path" contains
table={ { { 200, 100, 200, 184.0167, 200, 100 }, }, }
The end point and the second control point are the same, as in the PDF code. But how do I calculate the starting point and the first control point from the returned values?
something local prev = nil for i=1,#path do local current = path[i] if not prev then print(current[1],current[2],"m") else print(prev[5],prev[6],prev[3],prev[4],current[1],current[2],"c") end prev = current end -- close last to first if needed
And is the type of operation (line, curve,..) given by the number of values?
by analyzing using thresholds (one can just use "c" always, as "l" is an optimization) Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------