Login  Register

Re: Canvas: Transform Width and Height Independently

Posted by Nicolai Hess on Feb 21, 2015; 10:51am
URL: https://forum.world.st/Canvas-Transform-Width-and-Height-Independently-tp4806749p4806782.html



2015-02-21 4:50 GMT+01:00 Sean P. DeNigris <[hidden email]>:
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 :)

Good to know!

BTW I found a bug in isPureTranslation:
(MorphicTransform offset:10@10 angle:0 degreesToRadians  scale:1) isPureTranslation -> true
(MorphicTransform offset:10@10 angle:0 degreesToRadians  scale:1@1) isPureTranslation -> false



 

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
--
View this message in context: http://forum.world.st/Canvas-Transform-Width-and-Height-Independently-tp4806749p4806767.html
Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.