SourceForge logo
SourceForge logo
Menu

[matplotlib-devel] animation in SVG

From: tbhartman <tbh...@gm...> - 2015年02月27日 16:09:51
I trust this is an appropriate place; this is my first time on this listserv.
I want to add the ability to export an animation in SVG format so that I
have a vectorized animation. From what I've been able to discern, this
hasn't been done yet. I may have many questions related to this, so if
someone is familiar with this section of the code and would be able to
answer additional questions in the future, please let me know.
My first hurdle is how to extract each frame of the animation. I believe I
need to make a new class and inherit MovieWriter. However, MovieWriter is
setup to write an image to a file for each frame, then stitch those images
together (through a pipe to an external tool). But in order to add
animation to the SVG, it will be much easier for me to have an XML tree as
an object for each frame, rather than an XML file, so that I do not need to
re-parse the XML.
Here is where I am at:
* I've modified backend_svg.py:
 - an XMLBuilder class now builds the tree from the renderer (previously,
the XML data was written directly through XMLWriter)
 - currently, I have the svg backend (mostly) backward compatible so that I
can write images to file in the normal way. I have not run the example
tests yet, but need to eventually.
 - I added a draw method to FigureCanvasSVG which returns the XML tree
* I've modified animation.py:
 - added SVGWriter class which inherits MovieWriter
 - SVGWriter modifies setup method so that an external process is not
started
 - SVGWriter.grab_frame method grabs the XML tree (rather than printing to
a file) via FigureCanvasSVG.draw
 - SVGWriter.cleanup goes through the XML trees and adds 'set' XML elements
to create the animation
 * basically I copy the main group of each frame to a new XML tree and
make it's "opacity" CSS attribute 1 for the duration of that frame. It is a
hack to get the rest working...I'd like to actually go into the tree and
only change the data that changes in each frame.
I am at the point where I can get an SVG animation out of the moviewriter
example at:
http://matplotlib.org/examples/animation/moviewriter.html
However, FigureCanvas.draw does not seem the appropriate place for this. 
Case in point, the background is the default gray rather than white (which
you get if you savefig). Any thoughts on the best way to do this? 
-Tim
--
View this message in context: http://matplotlib.1069221.n5.nabble.com/animation-in-SVG-tp45021.html
Sent from the matplotlib - devel mailing list archive at Nabble.com.

View entire thread

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.
Thanks for helping keep SourceForge clean.
X





Briefly describe the problem (required):
Upload screenshot of ad (required):
Select a file, or drag & drop file here.
Screenshot instructions:

Click URL instructions:
Right-click on the ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)

More information about our ad policies

Ad destination/click URL:

AltStyle によって変換されたページ (->オリジナル) /