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. -- David Ripton [email protected] _______________________________________________ pygtk mailing list [email protected] http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://faq.pygtk.org/
