SourceForge logo
SourceForge logo
Menu

Re: [matplotlib-devel] animation -- ATTN backend maintainers

From: John H. <jdh...@ac...> - 2005年08月14日 21:06:31
>>>>> "Gregory" == Gregory Lielens <gre...@ff...> writes:
 Gregory> Hi John, Hi the list, I almost have finished updating the
 Gregory> fltkAgg, to add the new subplot formatter and the blit
 Gregory> method for fast animation. Everything seems to work fine,
 Gregory> but I still need to do some code clean-up, and before
 Gregory> commiting the changes I have to ask what you think about
 Gregory> the method I used:
Hi Gregory, Great news. Ken McIvor just emailed me this morning that
he completed the same with a _wxagg module that he will post shortly.
That means we have (or will soon have) blit methods for all GUIs
except Qt and Cocoa (gentle reminder).
 Gregory> Instead of writing a special method taking account of the
 Gregory> bbox for bliting, similar to the agg_to_gtk_drawable, or
 Gregory> a aggcanvas->str conversion like the proposed
 Gregory> aggcanvas.as_rgba_str(bbox), I just changed the method
 Gregory> that I introduced for normal draw in fltkAdd, that rely
 Gregory> on pytho buffer objects to transfer the agg buffer to the
 Gregory> fltk library.
 Gregory> The old method of the Agg backend that was used to get
 Gregory> the buffer object was:
 ....snip...
 Gregory> As fltkAgg is able to use an image source with a pixel
 Gregory> stride (skipping the a of the rgba quatuor) and a line
 Gregory> stride (taking a part of wide w1 from an image of wide
 Gregory> w2), no copy or special method is needed with the new
 Gregory> version of RendererAgg::buffer_rgba...
 Gregory> Now I checked and other backends (qtagg, cocoaagg) now
 Gregory> use RendererAgg::buffer_rgba. If this is ok, I will
 Gregory> update all the calls to pass (0,0) instead of no
 Gregory> arguments, but I wonder if the new methods could not
 Gregory> simplify things for those backends too...
Yep, this all looks right. I will look into this for gtkagg as well
tomorrow. It may make rendering to a bbox even faster because gtkagg
and tkagg may both make an unnecessary copy that your method avoids.
 Gregory> Another remarks is that the animation code seems quite
 Gregory> fragile for the moment: if one do a resize of the output
 Gregory> window, the background copy is not updated correctly and
 Gregory> one have a very interresting effect ;) Well, at leat I
 Gregory> observe that under fltkAgg (my local version supporting
 Gregory> blit) and GTKAgg. tkagg does not do this..because it is
 Gregory> not possible to resize the window during animation (well,
 Gregory> window is resizable but the size of the inside canvas
 Gregory> does not change during this resize...).
 Gregory> I think some extra steps should be performed to make
 Gregory> resize and anim play nicely together (like freezing the
 Gregory> anim during resize, and restarting afterwards with the
 Gregory> correct background...)
What I do is connect to the new 'draw_event' which is called at the
end of Figure.draw (no GUI specific event handling required). If you
set the animated property of the Artist, and then connect your
background saver to the 'draw_event', it should handle this case.
Additionally you want to make sure your draw events are processed in
an idle queue on resizes, etc.
Check out widgets.Cursor for a complete example using draw_event
background cacheing, the guts of which are 
 
 
 def __init__(self, ax, useblit=False, **lineprops):
 ...snip
 self.canvas.mpl_connect('draw_event', self.clear)
 def clear(self, event):
 'clear the cursor'
 if self.useblit:
 self.background = self.canvas.copy_from_bbox(self.ax.bbox)
Does this work for you in GTKAGG and/or FLTK? If everything looks
good, you may want to update the canonical animation examples in the
examples directory and on the wiki.
JDH

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 によって変換されたページ (->オリジナル) /