File: shapes.rst

package info (click to toggle)
svgwrite 1.4.3-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 2,304 kB
  • sloc: python: 12,524; makefile: 116; sh: 5
file content (233 lines) | stat: -rw-r--r-- 5,559 bytes parent folder | download
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
Line
====

.. autoclass:: svgwrite.shapes.Line

.. seealso:: http://www.w3.org/TR/SVG11/shapes.html#LineElement

.. automethod:: svgwrite.shapes.Line.__init__

SVG Attributes
--------------

* **x1** -- `<coordinate>` -- **start** parameter
* **y1** -- `<coordinate>` -- **start** parameter
* **x2** -- `<coordinate>` -- **end** parameter
* **y2** -- `<coordinate>` -- **end** parameter

Common SVG Attributes
---------------------

These are the common SVG Attributes for Line, Rect, Circle, Ellipse,
Poliyline and Polygon.

* **class** -- `string`

  assigns one or more css-class-names to an element

* **style** -- `string`

  allows per-element css-style rules to be specified directly on a given
  element

* **externalResourcesRequired** -- `bool`

  *False*: if document rendering can proceed even if external resources are
  unavailable else: *True*

* **transform** -- use :class:`svgwrite.mixins.Transform` interface

Common Standard SVG Attributes
------------------------------

These are the common Standard SVG Attributes for Line, Rect, Circle, Ellipse,
Poliyline and Polygon.

* :doc:`Core Attributes </attributes/core>`
* :doc:`Conditional Processing Attributes </attributes/conditional_processing>`
* :doc:`Graphical Event Attributes </attributes/graphical_event>`
* :doc:`Presentation Attributes </attributes/presentation>`

Parent Classes
--------------

* :class:`svgwrite.base.BaseElement`
* :class:`svgwrite.mixins.Transform`
* :class:`svgwrite.mixins.Presentation`
* :class:`svgwrite.mixins.Markers`

Rect
====

.. autoclass:: svgwrite.shapes.Rect

.. seealso:: http://www.w3.org/TR/SVG11/shapes.html#RectElement

.. automethod:: svgwrite.shapes.Rect.__init__

SVG Attributes
--------------

* **x** -- `<coordinate>` -- **insert** parameter

  The x-axis coordinate of the side of the
  rectangle which has the smaller x-axis coordinate value

* **y** -- `<coordinate>` -- **insert** parameter

  The y-axis coordinate of the side of the
  rectangle which has the smaller y-axis coordinate value

* **width** -- `<length>` -- **size** parameter

* **height** -- `<length>` -- **size** parameter

* **rx** -- `<length>` -- **rx** parameter

  For rounded rectangles, the y-axis radius of the
  ellipse used to round off the corners of the rectangle.

* **ry** -- `<length>` -- **ry** parameter

  For rounded rectangles, the y-axis radius of the
  ellipse used to round off the corners of the rectangle.


Parent Classes
--------------

* :class:`svgwrite.base.BaseElement`
* :class:`svgwrite.mixins.Transform`
* :class:`svgwrite.mixins.Presentation`

Circle
======

.. autoclass:: svgwrite.shapes.Circle

.. seealso:: http://www.w3.org/TR/SVG11/shapes.html#CircleElement

.. automethod:: svgwrite.shapes.Circle.__init__

SVG Attributes
--------------

* **cx** -- `<coordinate>` -- **center** parameter

  The x-axis coordinate of the center of the circle.

* **cy** -- `<coordinate>` -- **center** parameter

  The y-axis coordinate of the center of the circle.

* **r** -- `<length>` -- **r** parameter

  The radius of the circle.

Parent Classes
--------------

* :class:`svgwrite.base.BaseElement`
* :class:`svgwrite.mixins.Transform`
* :class:`svgwrite.mixins.Presentation`

Ellipse
=======

.. autoclass:: svgwrite.shapes.Ellipse

.. seealso:: http://www.w3.org/TR/SVG11/shapes.html#EllipseElement

.. automethod:: svgwrite.shapes.Ellipse.__init__

SVG Attributes
--------------

* **cx** -- `<coordinate>` -- **center** parameter

  The x-axis coordinate of the center of the ellipse.

* **cy** -- `<coordinate>` -- **center** parameter

  The y-axis coordinate of the center of the ellipse.

* **rx** -- `<length>` -- **r** parameter

  The x-axis radius of the ellipse.

* **ry** -- `<length>` -- **r** parameter

  The y-axis radius of the ellipse.

Parent Classes
--------------

* :class:`svgwrite.base.BaseElement`
* :class:`svgwrite.mixins.Transform`
* :class:`svgwrite.mixins.Presentation`

Polyline
========

.. autoclass:: svgwrite.shapes.Polyline

.. seealso:: http://www.w3.org/TR/SVG11/shapes.html#PolylineElement

.. automethod:: svgwrite.shapes.Polyline.__init__

Attributes
----------

.. attribute:: Polyline.points

   `list` of points, a point is a `2-tuple` (x, y): x, y = `<number>`

SVG Attributes
--------------

* **points** -- `list` of points  -- **points** parameter

  The points that make up the polyline. All coordinate values are in the
  **user coordinate system** (no units allowed).

How to append points::

    Polyline.points.append( point )
    Polyline.points.extend( [point1, point2, point3, ...] )

Parent Classes
--------------

* :class:`svgwrite.base.BaseElement`
* :class:`svgwrite.mixins.Transform`
* :class:`svgwrite.mixins.Presentation`
* :class:`svgwrite.mixins.Markers`

Polygon
=======

.. autoclass:: svgwrite.shapes.Polygon

.. seealso:: http://www.w3.org/TR/SVG11/shapes.html#PolygonElement

Parent Classes
--------------

* :class:`svgwrite.base.BaseElement`
* :class:`svgwrite.mixins.Transform`
* :class:`svgwrite.mixins.Presentation`
* :class:`svgwrite.mixins.Markers`

Basic Shapes Examples
=====================

.. literalinclude:: ../../examples/basic_shapes.py
   :lines: 16-

basic_shapes.svg
----------------

.. image:: ../../examples/basic_shapes.svg
   :width: 800
   :height: 800
   :alt: Your browser can't render SVG images.