/usr/share/doc/python3-pyx-doc/manual/canvas.html is in python3-pyx-doc 0.14.1-8.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Module canvas — PyX 0.14.1 Manual</title>
<link rel="stylesheet" href="_static/pyx.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: './',
VERSION: '0.14.1',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true,
SOURCELINK_SUFFIX: '.txt'
};
</script>
<script type="text/javascript" src="_static/jquery.js"></script>
<script type="text/javascript" src="_static/underscore.js"></script>
<script type="text/javascript" src="_static/doctools.js"></script>
<script type="text/javascript" src="_static/mathjax/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
<link rel="index" title="Index" href="genindex.html" />
<link rel="search" title="Search" href="search.html" />
<link rel="top" title="PyX 0.14.1 Manual" href="index.html" />
<link rel="next" title="Module document" href="document.html" />
<link rel="prev" title="Module deformer: Path deformers" href="deformer.html" />
</head>
<body>
<div class="relatedtop">
<div class="related">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="genindex.html" title="General Index"
accesskey="I">index</a></li>
<li class="right" >
<a href="py-modindex.html" title="Python Module Index"
>modules</a> |</li>
<li class="right" >
<a href="document.html" title="Module document"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="deformer.html" title="Module deformer: Path deformers"
accesskey="P">previous</a> |</li>
<li><a href="http://pyx.sourceforge.net">PyX Homepage</a> »</li>
<li><a href="manual.html">PyX 0.14.1 Manual</a> »</li>
<li>Module canvas</li>
</ul>
</div>
</div>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body">
<span class="target" id="module-canvas"></span><div class="section" id="id1">
<h1>Module <a class="reference internal" href="#module-canvas" title="canvas"><code class="xref py py-mod docutils literal"><span class="pre">canvas</span></code></a><a class="headerlink" href="#id1" title="Permalink to this headline">¶</a></h1>
<p>In addition it
contains the class <code class="docutils literal"><span class="pre">canvas.clip</span></code> which allows clipping of the output.</p>
<div class="section" id="class-canvas">
<h2>Class <a class="reference internal" href="#module-canvas" title="canvas"><code class="xref py py-class docutils literal"><span class="pre">canvas</span></code></a><a class="headerlink" href="#class-canvas" title="Permalink to this headline">¶</a></h2>
<p>This is the basic class of the canvas module. Instances of this class collect
visual elements like paths, other canvases, TeX or LaTeX elements. A canvas may
also be embedded in another one using its <code class="docutils literal"><span class="pre">insert</span></code> method. This may be useful
when you want to apply a transformation on a whole set of operations.</p>
<dl class="class">
<dt id="canvas.canvas">
<em class="property">class </em><code class="descclassname">canvas.</code><code class="descname">canvas</code><span class="sig-paren">(</span><em>attrs=[]</em>, <em>texrunner=None</em>, <em>ipython_bboxenlarge=1*unit.t_pt</em><span class="sig-paren">)</span><a class="headerlink" href="#canvas.canvas" title="Permalink to this definition">¶</a></dt>
<dd><p>Construct a new canvas, applying the given <em>attrs</em>, which can be instances of
<a class="reference internal" href="trafo.html#trafo.trafo" title="trafo.trafo"><code class="xref py py-class docutils literal"><span class="pre">trafo.trafo</span></code></a>, <code class="xref py py-class docutils literal"><span class="pre">canvas.clip</span></code>, <code class="xref py py-class docutils literal"><span class="pre">style.strokestyle</span></code> or
<code class="xref py py-class docutils literal"><span class="pre">style.fillstyle</span></code>. The <em>texrunner</em> argument can be used to specify the
texrunner instance used for the <a class="reference internal" href="text.html#module-text" title="text: High-level interface for text output including a TeX/LaTeX interface"><code class="xref py py-meth docutils literal"><span class="pre">text()</span></code></a> method of the canvas. If not
specified, it defaults to <em>text.defaulttexrunner</em>. <em>ipython_bboxenlarge</em> defines
the <cite>bboxenlarge</cite> <a class="reference internal" href="document.html#document.page" title="document.page"><code class="xref py py-class docutils literal"><span class="pre">document.page</span></code></a> for IPython’s <cite>_repr_png_</cite> and <cite>_repr_svg_</cite>.</p>
</dd></dl>
<p>Paths can be drawn on the canvas using one of the following methods:</p>
<dl class="method">
<dt id="canvas.canvas.draw">
<code class="descclassname">canvas.</code><code class="descname">draw</code><span class="sig-paren">(</span><em>path</em>, <em>attrs</em><span class="sig-paren">)</span><a class="headerlink" href="#canvas.canvas.draw" title="Permalink to this definition">¶</a></dt>
<dd><p>Draws <em>path</em> on the canvas applying the given <em>attrs</em>. Depending on the
<em>attrs</em> the path will be filled, stroked, ornamented, or a combination
thereof. For the common first two cases the following two convenience
functions are provided.</p>
</dd></dl>
<dl class="method">
<dt id="canvas.canvas.fill">
<code class="descclassname">canvas.</code><code class="descname">fill</code><span class="sig-paren">(</span><em>path</em>, <em>attrs=[]</em><span class="sig-paren">)</span><a class="headerlink" href="#canvas.canvas.fill" title="Permalink to this definition">¶</a></dt>
<dd><p>Fills the given <em>path</em> on the canvas applying the given <em>attrs</em>.</p>
</dd></dl>
<dl class="method">
<dt id="canvas.canvas.stroke">
<code class="descclassname">canvas.</code><code class="descname">stroke</code><span class="sig-paren">(</span><em>path</em>, <em>attrs=[]</em><span class="sig-paren">)</span><a class="headerlink" href="#canvas.canvas.stroke" title="Permalink to this definition">¶</a></dt>
<dd><p>Strokes the given <em>path</em> on the canvas applying the given <em>attrs</em>.</p>
</dd></dl>
<p>Arbitrary allowed elements like other <a class="reference internal" href="#module-canvas" title="canvas"><code class="xref py py-class docutils literal"><span class="pre">canvas</span></code></a> instances can be inserted
in the canvas using</p>
<dl class="method">
<dt id="canvas.canvas.insert">
<code class="descclassname">canvas.</code><code class="descname">insert</code><span class="sig-paren">(</span><em>item</em>, <em>attrs=[]</em><span class="sig-paren">)</span><a class="headerlink" href="#canvas.canvas.insert" title="Permalink to this definition">¶</a></dt>
<dd><p>Inserts an instance of <code class="xref py py-class docutils literal"><span class="pre">base.canvasitem</span></code> into the canvas. If <em>attrs</em> are
present, <em>item</em> is inserted into a new <a class="reference internal" href="#module-canvas" title="canvas"><code class="xref py py-class docutils literal"><span class="pre">canvas</span></code></a> instance with <em>attrs</em>
as arguments passed to its constructor. Then this <a class="reference internal" href="#module-canvas" title="canvas"><code class="xref py py-class docutils literal"><span class="pre">canvas</span></code></a> instance
is inserted itself into the canvas.</p>
</dd></dl>
<p>Text output on the canvas is possible using</p>
<dl class="method">
<dt id="canvas.canvas.text">
<code class="descclassname">canvas.</code><code class="descname">text</code><span class="sig-paren">(</span><em>x</em>, <em>y</em>, <em>text</em>, <em>attrs=[]</em><span class="sig-paren">)</span><a class="headerlink" href="#canvas.canvas.text" title="Permalink to this definition">¶</a></dt>
<dd><p>Inserts <em>text</em> at position (<em>x</em>, <em>y</em>) into the canvas applying <em>attrs</em>. This is
a shortcut for <code class="docutils literal"><span class="pre">insert(texrunner.text(x,</span> <span class="pre">y,</span> <span class="pre">text,</span> <span class="pre">attrs))</span></code>.</p>
</dd></dl>
<p>To group drawing operations, layers can be used:</p>
<dl class="method">
<dt id="canvas.canvas.layer">
<code class="descclassname">canvas.</code><code class="descname">layer</code><span class="sig-paren">(</span><em>name</em>, <em>above=None</em>, <em>below=None</em><span class="sig-paren">)</span><a class="headerlink" href="#canvas.canvas.layer" title="Permalink to this definition">¶</a></dt>
<dd><p>This method creates or gets a layer with name <em>name</em>.</p>
<p>A layer is a canvas itself and can be used to combine drawing operations for
ordering purposes, i.e., what is above and below each other. The layer name
<em>name</em> is a dotted string, where dots are used to form a hierarchy of layer
groups. When inserting a layer, it is put on top of its layer group except
when another layer instance of this group is specified by means of the
parameters <em>above</em> or <em>below</em>.</p>
</dd></dl>
<p>The <a class="reference internal" href="#module-canvas" title="canvas"><code class="xref py py-class docutils literal"><span class="pre">canvas</span></code></a> class provides access to the total geometrical size of its
element:</p>
<dl class="method">
<dt id="canvas.canvas.bbox">
<code class="descclassname">canvas.</code><code class="descname">bbox</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#canvas.canvas.bbox" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns the bounding box enclosing all elements of the canvas (see Sect. <a class="reference internal" href="bbox.html#module-bbox" title="bbox"><code class="xref py py-mod docutils literal"><span class="pre">bbox</span></code></a>).</p>
</dd></dl>
<p>A canvas also allows to set its TeX runner:</p>
<dl class="method">
<dt id="canvas.canvas.settexrunner">
<code class="descclassname">canvas.</code><code class="descname">settexrunner</code><span class="sig-paren">(</span><em>texrunner</em><span class="sig-paren">)</span><a class="headerlink" href="#canvas.canvas.settexrunner" title="Permalink to this definition">¶</a></dt>
<dd><p>Sets a new <em>texrunner</em> for the canvas.</p>
</dd></dl>
<p>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.</p>
<dl class="method">
<dt id="canvas.canvas.writeEPSfile">
<code class="descclassname">canvas.</code><code class="descname">writeEPSfile</code><span class="sig-paren">(</span><em>file</em>, <em>**kwargs</em><span class="sig-paren">)</span><a class="headerlink" href="#canvas.canvas.writeEPSfile" title="Permalink to this definition">¶</a></dt>
<dd><p>Writes the canvas to <em>file</em> using the EPS format. <em>file</em> either has to provide a
write method or it is used as a string containing the filename (the extension
<code class="docutils literal"><span class="pre">.eps</span></code> is appended automatically, if it is not present). This method
constructs a single page document, passing <em>kwargs</em> to the
<a class="reference internal" href="document.html#document.page" title="document.page"><code class="xref py py-class docutils literal"><span class="pre">document.page</span></code></a> constructor for all <em>kwargs</em> starting with <code class="docutils literal"><span class="pre">page_</span></code>
(without this prefix) and calls the <a class="reference internal" href="#canvas.canvas.writeEPSfile" title="canvas.canvas.writeEPSfile"><code class="xref py py-meth docutils literal"><span class="pre">writeEPSfile()</span></code></a> method of this
<a class="reference internal" href="document.html#document.document" title="document.document"><code class="xref py py-class docutils literal"><span class="pre">document.document</span></code></a> instance passing the <em>file</em> and all <em>kwargs</em>
starting with <code class="docutils literal"><span class="pre">write_</span></code> (without this prefix).</p>
</dd></dl>
<dl class="method">
<dt id="canvas.canvas.writePSfile">
<code class="descclassname">canvas.</code><code class="descname">writePSfile</code><span class="sig-paren">(</span><em>file</em>, <em>*args</em>, <em>**kwargs</em><span class="sig-paren">)</span><a class="headerlink" href="#canvas.canvas.writePSfile" title="Permalink to this definition">¶</a></dt>
<dd><p>Similar to <a class="reference internal" href="#canvas.canvas.writeEPSfile" title="canvas.canvas.writeEPSfile"><code class="xref py py-meth docutils literal"><span class="pre">writeEPSfile()</span></code></a> but using the PS format.</p>
</dd></dl>
<dl class="method">
<dt id="canvas.canvas.writePDFfile">
<code class="descclassname">canvas.</code><code class="descname">writePDFfile</code><span class="sig-paren">(</span><em>file</em>, <em>*args</em>, <em>**kwargs</em><span class="sig-paren">)</span><a class="headerlink" href="#canvas.canvas.writePDFfile" title="Permalink to this definition">¶</a></dt>
<dd><p>Similar to <a class="reference internal" href="#canvas.canvas.writeEPSfile" title="canvas.canvas.writeEPSfile"><code class="xref py py-meth docutils literal"><span class="pre">writeEPSfile()</span></code></a> but using the PDF format.</p>
</dd></dl>
<dl class="method">
<dt id="canvas.canvas.writeSVGfile">
<code class="descclassname">canvas.</code><code class="descname">writeSVGfile</code><span class="sig-paren">(</span><em>file</em>, <em>*args</em>, <em>**kwargs</em><span class="sig-paren">)</span><a class="headerlink" href="#canvas.canvas.writeSVGfile" title="Permalink to this definition">¶</a></dt>
<dd><p>Similar to <a class="reference internal" href="#canvas.canvas.writeEPSfile" title="canvas.canvas.writeEPSfile"><code class="xref py py-meth docutils literal"><span class="pre">writeEPSfile()</span></code></a> but using the SVG format.</p>
</dd></dl>
<dl class="method">
<dt id="canvas.canvas.writetofile">
<code class="descclassname">canvas.</code><code class="descname">writetofile</code><span class="sig-paren">(</span><em>filename</em>, <em>*args</em>, <em>**kwargs</em><span class="sig-paren">)</span><a class="headerlink" href="#canvas.canvas.writetofile" title="Permalink to this definition">¶</a></dt>
<dd><p>Determine the file type (EPS, PS, PDF, or SVG) from the file extension of <em>filename</em>
and call the corresponding write method with the given arguments <em>arg</em> and
<em>kwargs</em>.</p>
</dd></dl>
<dl class="method">
<dt id="canvas.canvas.pipeGS">
<code class="descclassname">canvas.</code><code class="descname">pipeGS</code><span class="sig-paren">(</span><em>device</em>, <em>resolution=100</em>, <em>gs="gs"</em>, <em>gsoptions=[]</em>, <em>textalphabits=4</em>, <em>graphicsalphabits=4</em>, <em>ciecolor=False</em>, <em>input="eps"</em>, <em>**kwargs</em><span class="sig-paren">)</span><a class="headerlink" href="#canvas.canvas.pipeGS" title="Permalink to this definition">¶</a></dt>
<dd><p>This method pipes the content of a canvas to the ghostscript interpreter
to generate other output formats. The output is returned by means of a
python BytesIO object. <em>device</em> specifies a ghostscript output device by
a string. Depending on the ghostscript configuration <code class="docutils literal"><span class="pre">"png16"</span></code>,
<code class="docutils literal"><span class="pre">"png16m"</span></code>, <code class="docutils literal"><span class="pre">"png256"</span></code>, <code class="docutils literal"><span class="pre">"png48"</span></code>, <code class="docutils literal"><span class="pre">"pngalpha"</span></code>, <code class="docutils literal"><span class="pre">"pnggray"</span></code>,
<code class="docutils literal"><span class="pre">"pngmono"</span></code>, <code class="docutils literal"><span class="pre">"jpeg"</span></code>, and <code class="docutils literal"><span class="pre">"jpeggray"</span></code> might be available among
others. See the output of <code class="docutils literal"><span class="pre">gs</span> <span class="pre">--help</span></code> and the ghostscript documentation
for more information.</p>
<p><em>resolution</em> specifies the resolution in dpi (dots per inch). <em>gs</em> is the
name of the ghostscript executable. <em>gsoptions</em> is a list of additional
options passed to the ghostscript interpreter. <em>textalphabits</em> and
<em>graphicsalphabits</em> are convenient parameters to set the <code class="docutils literal"><span class="pre">TextAlphaBits</span></code>
and <code class="docutils literal"><span class="pre">GraphicsAlphaBits</span></code> options of ghostscript. The addition of these
options can be skipped by setting their values to <code class="docutils literal"><span class="pre">None</span></code>. <em>ciecolor</em> adds
the <code class="docutils literal"><span class="pre">-dUseCIEColor</span></code> flag to improve the CMYK to RGB color conversion.
<em>input</em> can be either <code class="docutils literal"><span class="pre">"eps"</span></code> or <code class="docutils literal"><span class="pre">"pdf"</span></code> to select the input type to be
passed to ghostscript (note slightly different features available in the
different input types regarding e.g. <a class="reference internal" href="epsfile.html#module-epsfile" title="epsfile"><code class="xref py py-mod docutils literal"><span class="pre">epsfile</span></code></a> inclusion and
transparency).</p>
<p><em>kwargs</em> are passed to the <a class="reference internal" href="#canvas.canvas.writeEPSfile" title="canvas.canvas.writeEPSfile"><code class="xref py py-meth docutils literal"><span class="pre">writeEPSfile()</span></code></a> method (not counting the <em>file</em>
parameter), which is used to generate the input for ghostscript. By that you
gain access to the <a class="reference internal" href="document.html#document.page" title="document.page"><code class="xref py py-class docutils literal"><span class="pre">document.page</span></code></a> constructor arguments.</p>
</dd></dl>
<dl class="method">
<dt id="canvas.canvas.writeGSfile">
<code class="descclassname">canvas.</code><code class="descname">writeGSfile</code><span class="sig-paren">(</span><em>filename=None</em>, <em>device=None</em>, <em>**kwargs</em><span class="sig-paren">)</span><a class="headerlink" href="#canvas.canvas.writeGSfile" title="Permalink to this definition">¶</a></dt>
<dd><p>This method is similar to pipeGS, but the content is written into the file
<em>filename</em>. If filename is None it is auto-guessed from the script name. If
filename is “-“, the output is written to stdout. In both cases, a device
needs to be specified to define the format (and the file suffix in case the
filename is created from the script name).</p>
<p>If device is None, but a filename with suffix is given, PNG files will
be written using the png16m device and JPG files using the jpeg device.</p>
<p>All other arguments are identical to those of the <a class="reference internal" href="#canvas.canvas.pipeGS" title="canvas.canvas.pipeGS"><code class="xref py py-meth docutils literal"><span class="pre">canvas.pipeGS()</span></code></a>.</p>
</dd></dl>
<p>For more information about the possible arguments of the <a class="reference internal" href="document.html#document.page" title="document.page"><code class="xref py py-class docutils literal"><span class="pre">document.page</span></code></a>
constructor, we refer to Sect. <a class="reference internal" href="document.html#module-document" title="document"><code class="xref py py-mod docutils literal"><span class="pre">document</span></code></a>.</p>
</div>
<div class="section" id="class-clip">
<h2>Class <code class="xref py py-class docutils literal"><span class="pre">clip</span></code><a class="headerlink" href="#class-clip" title="Permalink to this headline">¶</a></h2>
<p>In addition the canvas module contains the class <code class="docutils literal"><span class="pre">canvas.clip</span></code> which allows for
clipping of the output by passing a clipping instance to the attrs parameter of
the canvas constructor.</p>
</div>
</div>
</div>
</div>
</div>
<div class="sphinxsidebar">
<div class="sphinxsidebarwrapper">
<div class="sidebarbox">
<h3><a href="manual.html">Table Of Contents</a></h3>
<ul>
<li><a class="reference internal" href="#">Module <code class="docutils literal"><span class="pre">canvas</span></code></a><ul>
<li><a class="reference internal" href="#class-canvas">Class <code class="docutils literal"><span class="pre">canvas</span></code></a></li>
<li><a class="reference internal" href="#class-clip">Class <code class="docutils literal"><span class="pre">clip</span></code></a></li>
</ul>
</li>
</ul>
</div>
<div class="sidebarbox">
<div role="note" aria-label="source link">
<h3>This Page</h3>
<ul class="this-page-menu">
<li><a href="_sources/canvas.rst.txt"
rel="nofollow">Show Source</a></li>
</ul>
</div></div>
<div class="sidebarbox">
<div id="searchbox" style="display: none" role="search">
<h3>Quick search</h3>
<form class="search" action="search.html" method="get">
<div><input type="text" name="q" /></div>
<div><input type="submit" value="Go" /></div>
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script></div>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="relatedbottom">
<div class="related">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="genindex.html" title="General Index"
>index</a></li>
<li class="right" >
<a href="py-modindex.html" title="Python Module Index"
>modules</a> |</li>
<li class="right" >
<a href="document.html" title="Module document"
>next</a> |</li>
<li class="right" >
<a href="deformer.html" title="Module deformer: Path deformers"
>previous</a> |</li>
<li><a href="http://pyx.sourceforge.net">PyX Homepage</a> »</li>
<li><a href="manual.html">PyX 0.14.1 Manual</a> »</li>
<li>Module canvas</li>
</ul>
</div>
</div>
<div class="footer">
© Copyright 2017, Jörg Lehmann, Michael Schindler, André Wobst.
Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.6.5.
</div>
</body>
</html>
|