On Sat, Jun 20, 2009 at 1:05 AM, David Ripton <[email protected]> wrote:
> On 2009.06.20 00:39:54 +0530, Manavan J wrote: > > I am wondering how a 2D canvas would be implemented. I think of the > > following steps as its core design. > > > > 1. For all the objects to be displayed create a Spatial Index > > 2. At the time of display, iterate through all shapes that overlap the > > view area and zoom > > 3. Display these in the drawing area after appropriate transformation. > > > > Please advice if there is a better way that is adopted. If this is the > usual > > technique, which kind of Spatial index is usually used for a zoomable > canvas > > widget. > > When I wrote a PyGTK + Cairo canvas (closed source), I just used simple > z-order. > > Put all the displayable objects in a list. Draw in list order. > Hit-test in reverse list order. > > So objects at the beginning of the list are on the bottom, and objects > at the end of the list are on the top. > > This is very simple. It's not very efficient if you have lots of > overlapping objects, because you end up drawing even the ones that are > completely hidden behind others. But it works. <http://faq.pygtk.org/> > David, Thanks for the reply. In my case I am more concerned about the zoom-ability of the canvas. The state of the art seems to be in a Java library called Piccolo. There is a IEEE paper on the publications section. I think I need to go through it. Anybody know the gist of what they are doing in Piccolo? How is hit test done? By using quadtree, R-tree.. ? Which is more suitable? Regards, Suresh
_______________________________________________ pygtk mailing list [email protected] http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://faq.pygtk.org/
