Thank you Werner and Nicolai! You were both right :) The transform offset
needed to be scaled and the clipping needed to be both translated and
scaled, too.

The final code was:
        morph := Morph new 
                        topLeft: 200@400; 
                        openInWorld. 
        outputRect := morph fullBounds. 
        scale := 0.2.
        canvas := Display defaultCanvasClass extent: outputRect extent * scale
depth: 
Display depth.  
        t := MorphicTransform offset: outputRect topLeft * scale angle: 0 scale:
scale. "*** must scale offset"
        clipRect := (outputRect translateBy: outputRect topLeft negated) 
scaleBy:
scale. "*** must translate and scale clip rect"
        canvas transformBy: t clippingTo: clipRect during: [ :aCanvas | 
                aCanvas fullDrawMorph: morph ].

This seems so complicated. I would naively think that the API should do much
of this for you. For example, why doesn't it know that when there's an
offset AND a scale, the transform's offset should be adjusted by the scale?
        canvas form asMorph openInWindow. 



-----
Cheers,
Sean
--
View this message in context: 
http://forum.world.st/Canvas-Transform-Goes-Haywire-if-Scaled-tp4803830p4803963.html
Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.

Reply via email to