[pygtk] Canvas Design Principle
Manavan J
manavan.j at gmail.com
Sat Jun 20 13:06:09 WST 2009
On Sat, Jun 20, 2009 at 1:05 AM, David Ripton <dripton at ripton.net> 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.daa.com.au/pipermail/pygtk/attachments/20090620/ae96b49c/attachment.htm
More information about the pygtk
mailing list