Login  Register

Re: Canvas: Transform Width and Height Independently

Posted by Sean P. DeNigris on Feb 21, 2015; 3:50am
URL: https://forum.world.st/Canvas-Transform-Width-and-Height-Independently-tp4806749p4806767.html

Sean P. DeNigris wrote
That worked
But actually, it was totally unnecessary! MorphicTransform's scaling method arguments were either named (unhelpfully) 's' or (misleadingly) 'aFloat', but apparently, I can just pass aPoint to scale x and y separately :)

So I'm back to the simple version...
drawOn: aCanvas

        | transform widthScale heightScale |
        widthScale := self innerBounds width / self image width.
        heightScale := self innerBounds height / self image height.
        transform := MorphicTransform new withScale: widthScale@heightScale.
        aCanvas warpImage: self image transform: transform at: self innerBounds origin

Thanks for talking me through it! I learned a lot...
Cheers,
Sean