From cf07d6f08065522063d82365c9e22ccd6d44ef9c Mon Sep 17 00:00:00 2001 From: =?utf8?q?Andr=C3=A9=20Wobst?= Date: Wed, 29 Apr 2015 21:52:12 +0000 Subject: [PATCH] document the new SVG output git-svn-id: http://svn.code.sf.net/p/pyx/code/trunk/pyx@3634 a4f5e268-e194-4f32-bce1-d30804cbbcc5 --- manual/canvas.rst | 17 ++++++++++++----- manual/document.rst | 12 +++++++++++- manual/graph.rst | 11 +++++------ manual/graphics.rst | 6 +++++- 4 files changed, 33 insertions(+), 13 deletions(-) diff --git a/manual/canvas.rst b/manual/canvas.rst index 9d40d511..65edb4c4 100644 --- a/manual/canvas.rst +++ b/manual/canvas.rst @@ -101,14 +101,16 @@ The contents of the canvas can be written to a file using the following convenience methods, which wrap the canvas into a single page document. -.. method:: canvas.writeEPSfile(file, *args, **kwargs) +.. method:: canvas.writeEPSfile(file, **kwargs) Writes the canvas to *file* using the EPS format. *file* either has to provide a write method or it is used as a string containing the filename (the extension ``.eps`` is appended automatically, if it is not present). This method - constructs a single page document, passing *args* and *kwargs* to the - :class:`document.page` constructor and calls the :meth:`writeEPSfile` method - of this :class:`document.document` instance passing the *file*. + constructs a single page document, passing *kwargs* to the + :class:`document.page` constructor for all *kwargs* starting with ``page_`` + (without this prefix) and calls the :meth:`writeEPSfile` method of this + :class:`document.document` instance passing the *file* and all *kwargs* + starting with ``write_`` (without this prefix). .. method:: canvas.writePSfile(file, *args, **kwargs) @@ -121,9 +123,14 @@ convenience methods, which wrap the canvas into a single page document. Similar to :meth:`writeEPSfile` but using the PDF format. +.. method:: canvas.writeSVGfile(file, *args, **kwargs) + + Similar to :meth:`writeEPSfile` but using the SVG format. + + .. method:: canvas.writetofile(filename, *args, **kwargs) - Determine the file type (EPS, PS, or PDF) from the file extension of *filename* + Determine the file type (EPS, PS, PDF, or SVG) from the file extension of *filename* and call the corresponding write method with the given arguments *arg* and *kwargs*. diff --git a/manual/document.rst b/manual/document.rst index f2722661..df0bbed4 100644 --- a/manual/document.rst +++ b/manual/document.rst @@ -71,9 +71,19 @@ A :class:`document` can be written to a file using one of the following methods: parameters are identical to the :meth:`writeEPSfile`. +.. method:: document.writeSVGfile(file, text_as_path=True, mesh_as_bitmap_resolution=300) + + Write :class:`document` to a SVG file or to stdout if *file* is set to *-*. + The *text_as_path* and *mesh_as_bitmap_resolution* have the same meaning as + in :meth:`writeEPSfile`. However, not the different default for + *text_as_path* due to the missing SVG font support by current browsers. + In addition, there is no *mesh_as_bitmap* flag, as meshs are always stored + using bitmaps in SVG. + + .. method:: document.writetofile(filename, *args, **kwargs) - Determine the file type (EPS, PS, or PDF) from the file extension of *filename* + Determine the file type (EPS, PS, PDF, or SVG) from the file extension of *filename* and call the corresponding write method with the given arguments *arg* and *kwargs*. diff --git a/manual/graph.rst b/manual/graph.rst index 78349385..c705eadc 100644 --- a/manual/graph.rst +++ b/manual/graph.rst @@ -61,13 +61,12 @@ following line:: g.plot(graph.data.function("y(x)=x**2")) You can plot different data in a single graph by calling :meth:`plot` several -times before :meth:`writeEPSfile` or :meth:`writePDFfile`. Note that a calling -:meth:`plot` will fail once a graph was forced to "finish" itself. This happens +times before writing the output to a file. Note that a calling :meth:`plot` +will fail once a graph was forced to "finish" itself. This happens automatically, when the graph is written to a file. Thus it is not an option to -call :meth:`plot` after :meth:`writeEPSfile` or :meth:`writePDFfile`. The topic -of the finalization of a graph is addressed in more detail in section -:mod:`graph.graph`. As you can see in figure :ref:`fig_graph2`, a function is -plotted as a line by default. +call :meth:`plot` after writing the output. The topic of the finalization of a +graph is addressed in more detail in section :mod:`graph.graph`. As you can see +in figure :ref:`fig_graph2`, a function is plotted as a line by default. .. _fig_graph2: .. figure:: graph2.* diff --git a/manual/graphics.rst b/manual/graphics.rst index 8f7d5c10..891a8ebe 100644 --- a/manual/graphics.rst +++ b/manual/graphics.rst @@ -51,10 +51,14 @@ In order to draw the path on the canvas, we use the :meth:`stroke` method of the To complete the example, we have added a :meth:`writeEPSfile` call, which writes the contents of the canvas to the file :file:`line.eps`. Note that an extension :file:`.eps` is added automatically, if not already present in the given -filename. Similarly, if you want to generate a PDF file instead, use :: +filename. Similarly, if you want to generate a PDF or SVG file instead, use :: c.writePDFfile("line") +or + + c.writeSVGfile("line") + As a second example, let us define a path which consists of more than one subpath:: -- 2.11.4.GIT