From: Benjamin R. <ben...@ou...> - 2015-02-28 14:46:59
|
It sounds like you are on the right path, and you do raise some interesting points. I would certainly be open to accepting improvements to the animation framework to facilitate this work. As for the gray vs. white backgrounds, I am not all that familiar with how that is handled, but IIRC, the non-interactive backends obtain the background color from the rcparams. I would love to see a PR for your efforts so far. An SVG animator would also be valuable as a way to add unit-tests to the animation framework since it would be easier to do comparisons, I would think. On Fri, Feb 27, 2015 at 11:09 AM, tbhartman <tbh...@gm...> wrote: > 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. > > > ------------------------------------------------------------------------------ > Dive into the World of Parallel Programming The Go Parallel Website, > sponsored > by Intel and developed in partnership with Slashdot Media, is your hub for > all > things parallel software development, from weekly thought leadership blogs > to > news, videos, case studies, tutorials and more. Take a look and join the > conversation now. http://goparallel.sourceforge.net/ > _______________________________________________ > Matplotlib-devel mailing list > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-devel > |