From: Joel VanderWerf Date: 2009-09-08T04:26:32+09:00 Subject: Re: Zoomable TkCanvas? Josef Wolf wrote: > It looks like TkCanvas has no methods for zooming in and out. For Perl, I > have found the Tk::Worldcanvas and Tk::Abstractcanvas modules. Anybody knows > about something like that for ruby? Those perl modules sound interesting--maybe it would be useful to have them in ruby if someone hasn't done that yet. I've used Tk's Canvas from tcl and from ruby, and I've always had to implement zooming myself in wrapper classes. One way to do it is tag all canvas objects (or just the ones that zoom), and use the Canvas#scale method on that tag. You have to keep track of the current zoom level (Tk doesn't), and use that to calculate the arguments to #scale. You also have to adjust the scroll bars (using 'configure :scrollregion => ...'). Then use xview/yview to keep the current view position in sync with the zoom level. I think that covers it, but if you're interested, take a look at canvas.rb in my tkar project. Tkar is a process, rather than a library, but it abstracts out details like zooming and provides a basic user interface for controlling zoom, pan, etc. http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/343516 http://rubyforge.org/projects/tkar -- vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407