[PD] Tk Zoom

Mathieu Bouchard matju at artengine.ca
Wed Feb 22 19:32:21 CET 2012


Le 2012-02-22 à 09:31:00, Hans-Christoph Steiner a écrit :
> On Feb 22, 2012, at 12:48 AM, Mathieu Bouchard wrote:
>> How do you do zooming with Tcl/Tk ?
>> I mean... I implemented zooming using a big workaround which wouldn't have worked with Pd externals... is there a trouble-free way to zoom ?
>
> Didn't you use Tk scaling?  That's what I mean. Yes, this would not work with existing GUI objects.

« Tk Scaling » is the name of a font measurement ratio for pt/px 
conversions, right ?

TkCanvas' «scale» command is unrelated, and does not do zoom, because it 
changes the size of items. The difference between that and zoom is that Tk 
doesn't make you see the prescaled coordinates, it still interacts with 
you only in terms of actual pixels. This means that most of the time, 
you'd have to scale the values on your own using [expr {$x*$scale}] and 
stuff.

In DesireData, I avoid TkCanvas's «scale» command entirely, and I make 
every canvas item creation/modification through a function that scans the 
arguments of the item, scales all coords it sees, scales the thickness of 
lines, scales the font sizes, automatically decides tags to be used, and 
figures out what to do differently in create vs modify.

That way, the widget's behaviour does not have to implement zoom, it does 
not have to implement modification-functions (because the create-function 
is able to redraw an existing thing), it does not have to implement the 
delete-function (because the enforced common tag makes a single command 
delete), etc.

That's not compatible with t_widgetbehavior and couldn't possibly be made 
to be.

  ______________________________________________________________________
| Mathieu BOUCHARD ----- téléphone : +1.514.383.3801 ----- Montréal, QC


More information about the Pd-list mailing list