I want to read/write asymptote
cyclic path
definitions from/to files. For example, while running asymptote
code, I want to build up an arbitrary cyclic path
and write that path information to an external file for later inclusion in another asymptote
run.
Is there already an easy solution for this?
If not, my thought is to loop thru the path
nodes and use the point
, precontrol
, and postcontrol
functions to write
a string of the form...
path p = (0,0)..controls (0,100) and (100,100)..(100,0) and so on
to an external file and then include that file in the later asymptote
run. Does anyone know of an easier way?
write(file, p);
wherep
is the name of the path andfile
is the file you want (e.g.stdout
works for a quick test). Preface it with writing the string'path p = '
and append a';'
to get aninclude
able file.write
command would work for that. If you want to put that info in an answer I will certainly accept it.include
statement is executed at runtime or compile time; if the latter, then any changes made to the file during the currentasy
run would be omitted.) Anyway, I suspect that this version ofwrite
was included mainly for debugging purposes (which is also how I came across it; I was debugging and wanted to check if the "lazy" code worked before writing something more elaborate).