···
[](https://github.com/cduck/drawSvg/blob/master/examples/example4.svg)
184
+
### Animation with the SVG Animate Tag
186
+
import drawSvg as draw
188
+
d = draw.Drawing(200, 200, origin='center')
190
+
# Animate the position and color of circle
191
+
c = draw.Circle(0, 0, 20, fill='red')
192
+
# See for supported attributes:
193
+
# https://developer.mozilla.org/en-US/docs/Web/SVG/Element/animate
194
+
c.appendAnim(draw.Animate('cy', '6s', '-80;80;-80',
195
+
repeatCount='indefinite'))
196
+
c.appendAnim(draw.Animate('cx', '6s', '0;80;0;-80;0',
197
+
repeatCount='indefinite'))
198
+
c.appendAnim(draw.Animate('fill', '6s', 'red;green;blue;yellow',
199
+
calcMode='discrete',
200
+
repeatCount='indefinite'))
203
+
# Animate a black circle around an ellipse
204
+
ellipse = draw.Path()
206
+
ellipse.A(90, 40, 360, True, True, 90, 0) # Ellipse path
207
+
ellipse.A(90, 40, 360, True, True, -90, 0)
209
+
c2 = draw.Circle(0, 0, 10)
210
+
# See for supported attributes:
211
+
# https://developer.mozilla.org/en-US/docs/Web/SVG/Element/animateMotion
212
+
c2.appendAnim(draw.AnimateMotion(ellipse, '3s',
213
+
repeatCount='indefinite'))
214
+
# See for supported attributes:
215
+
# https://developer.mozilla.org/en-US/docs/Web/SVG/Element/animateTransform
216
+
c2.appendAnim(draw.AnimateTransform('scale', '3s', '1,2;2,1;1,2;2,1;1,2',
217
+
repeatCount='indefinite'))
220
+
d.saveSvg('animated.svg') # Save to file
221
+
d # Display in Jupyter notebook
224
+
[](https://github.com/cduck/drawSvg/blob/master/examples/animated.svg)
···

275
+
### Animation with Python
···

286
-
### SVG-Native Animation
288
-
import drawSvg as draw
290
-
d = draw.Drawing(200, 200, origin='center')
292
-
# Animate the position and color of circle
293
-
c = draw.Circle(0, 0, 20, fill='red')
294
-
# See for supported attributes:
295
-
# https://developer.mozilla.org/en-US/docs/Web/SVG/Element/animate
296
-
c.appendAnim(draw.Animate('cy', '6s', '-80;80;-80',
297
-
repeatCount='indefinite'))
298
-
c.appendAnim(draw.Animate('cx', '6s', '0;80;0;-80;0',
299
-
repeatCount='indefinite'))
300
-
c.appendAnim(draw.Animate('fill', '6s', 'red;green;blue;yellow',
301
-
calcMode='discrete',
302
-
repeatCount='indefinite'))
305
-
# Animate a black circle around an ellipse
306
-
ellipse = draw.Path()
308
-
ellipse.A(90, 40, 360, True, True, 90, 0) # Ellipse path
309
-
ellipse.A(90, 40, 360, True, True, -90, 0)
311
-
c2 = draw.Circle(0, 0, 10)
312
-
# See for supported attributes:
313
-
# https://developer.mozilla.org/en-US/docs/Web/SVG/Element/animateMotion
314
-
c2.appendAnim(draw.AnimateMotion(ellipse, '3s',
315
-
repeatCount='indefinite'))
316
-
# See for supported attributes:
317
-
# https://developer.mozilla.org/en-US/docs/Web/SVG/Element/animateTransform
318
-
c2.appendAnim(draw.AnimateTransform('scale', '3s', '1,2;2,1;1,2;2,1;1,2',
319
-
repeatCount='indefinite'))
322
-
d.saveSvg('/Users/cduck/Downloads/animated.svg') # Save to file
323
-
d # Display in Jupyter notebook
326
-
[](https://github.com/cduck/drawSvg/blob/master/examples/animated.svg)