Jeroen Demeyer on Tue, 17 Jan 2017 10:42:31 +0100 |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
Re: [PATCH] Implement SVG plotting |
On 2017-01-14 17:56, Bill Allombert wrote:
How do you envision SVG to be used under GP ? How libpari program will be able to use graphics ?
1. Graphics in general:First of all, my latest version of my patches (see the jeroen-svg branch) adds a new option to pari_init() called INIT_GRAPHm. This option should be used whenever graphics are needed.
Second, some variant of PARI_get_plot_FOO() needs to be called to select the plotting backend. For example, PARI_get_plot_X() for X11 or PARI_get_plot_svg() for SVG. It is legal to change the plotting backend at runtime by calling a different PARI_get_plot_BAR() function.
Now, the PARI plotting functions can be called. 2. SVG specifics: For SVG plotting, there is a new callback function void cb_plot_svg(const char *svg)which will be called whenever an SVG image is produced. The SVG code (as 0-terminated string) will be passed as the argument. The application can then do whatever it wants. By default, cb_plot_svg=pari_puts so the SVG will simply be printed.
3. gp specifics:Within gp, there should probably be a new default to select the plotting backend. Something like
default(graphic, "X")for X11 plotting for example. Then sd_graphic() should call the corresponding PARI_get_plot_FOO() function. For SVG plotting, I suggest to write to a file (analogously to ps plotting). So there should be a default(svgfile) and a callback function which writes its argument to the svgfile.
4. psplotCurrently, ps plotting is implemented independently from other plotting engines with separate functions. In the future, this should probably be changed and it should just be another plotting backend.