I'm implementing a SimpleImageMorph which squeezes the form into the Morph's inner bounds instead of the weird TransformMorph thing. As a spike, I wrote: | transform scale | scale := self innerBounds width / self image width. transform := MorphicTransform new setScale: scale. aCanvas warpImage: self image transform: transform at: self innerBounds origin But obviously this only takes the width into account. How would I transform both of the forms dimensions to the corresponding dimension of the morph's inner bounds? ----- Cheers, Sean -- View this message in context: http://forum.world.st/Canvas-Transform-Width-and-Height-Independently-tp4806... Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.
2015-02-20 23:56 GMT+01:00 Sean P. DeNigris <sean@clipperadams.com>:
I'm implementing a SimpleImageMorph which squeezes the form into the Morph's inner bounds instead of the weird TransformMorph thing.
As a spike, I wrote: | transform scale | scale := self innerBounds width / self image width. transform := MorphicTransform new setScale: scale. aCanvas warpImage: self image transform: transform at: self innerBounds origin
But obviously this only takes the width into account. How would I transform both of the forms dimensions to the corresponding dimension of the morph's inner bounds?
I think there is no direct support in Canvas API. You can create a new Form warpblt into this form use the canvas to draw the new form |f| f:=Form extent:100@400 depth:32. (WarpBlt current toForm: f) sourceForm: PolymorphSystemSettings pharoLogoForm destRect: f boundingBox; combinationRule: Form paint; cellSize:2; warpBits. f asMorph openInHand
----- Cheers, Sean -- View this message in context: http://forum.world.st/Canvas-Transform-Width-and-Height-Independently-tp4806... Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.
And there is FormCanvas>>#warpImage:transform:at:sourceRect:cellSize: this one works with a MatrixTransform2x3 (this may support scaling for x and y). 2015-02-21 0:40 GMT+01:00 Nicolai Hess <nicolaihess@web.de>:
2015-02-20 23:56 GMT+01:00 Sean P. DeNigris <sean@clipperadams.com>:
I'm implementing a SimpleImageMorph which squeezes the form into the Morph's inner bounds instead of the weird TransformMorph thing.
As a spike, I wrote: | transform scale | scale := self innerBounds width / self image width. transform := MorphicTransform new setScale: scale. aCanvas warpImage: self image transform: transform at: self innerBounds origin
But obviously this only takes the width into account. How would I transform both of the forms dimensions to the corresponding dimension of the morph's inner bounds?
I think there is no direct support in Canvas API. You can create a new Form warpblt into this form use the canvas to draw the new form
|f| f:=Form extent:100@400 depth:32. (WarpBlt current toForm: f) sourceForm: PolymorphSystemSettings pharoLogoForm destRect: f boundingBox; combinationRule: Form paint; cellSize:2; warpBits. f asMorph openInHand
----- Cheers, Sean -- View this message in context: http://forum.world.st/Canvas-Transform-Width-and-Height-Independently-tp4806... Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.
Nicolai Hess wrote
You can create a new Form... warpblt into this form...
Ah, thanks. That worked. It became: drawOn: aCanvas | tempForm | tempForm := Form extent: self innerBounds extent depth: self image depth. (WarpBlt current toForm: tempForm) sourceForm: self image destRect: tempForm relativeRectangle; combinationRule: Form paint; cellSize: 1; warpBits. aCanvas drawImage: tempForm at: self innerBounds origin ----- Cheers, Sean -- View this message in context: http://forum.world.st/Canvas-Transform-Width-and-Height-Independently-tp4806... Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.
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 -- View this message in context: http://forum.world.st/Canvas-Transform-Width-and-Height-Independently-tp4806... Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.
Sean P. DeNigris wrote
MorphicTransform's scaling method arguments were either named (unhelpfully) 's' or (misleadingly) 'aFloat'
Issue 14971 MorphicTransform: Better Argument Names Fix in inbox... Scale: "s" -> aNumberOrPoint Angle: "a" -> radians Offset: a -> aPoint ----- Cheers, Sean -- View this message in context: http://forum.world.st/Canvas-Transform-Width-and-Height-Independently-tp4806... Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.
Le 21/2/15 05:23, Sean P. DeNigris a écrit :
Sean P. DeNigris wrote
MorphicTransform's scaling method arguments were either named (unhelpfully) 's' or (misleadingly) 'aFloat'
Issue 14971 MorphicTransform: Better Argument Names Fix in inbox... Scale: "s" -> aNumberOrPoint Angle: "a" -> radians Offset: a -> aPoint
wonderful! Stef
----- Cheers, Sean -- View this message in context: http://forum.world.st/Canvas-Transform-Width-and-Height-Independently-tp4806... Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.
2015-02-21 4:50 GMT+01:00 Sean P. DeNigris <sean@clipperadams.com>:
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-tp4806... Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.
Sean Could you write a little doc on what you learned? I would love to read it. Stef Le 21/2/15 04:50, Sean P. DeNigris a écrit :
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 -- View this message in context: http://forum.world.st/Canvas-Transform-Width-and-Height-Independently-tp4806... Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.
stepharo wrote
Could you write a little doc on what you learned?
I have to think about it. There were a lot of little ahas, but I don't know how to summarize it... The biggest realization was that "canvases + transforms" is extremely powerful! ----- Cheers, Sean -- View this message in context: http://forum.world.st/Canvas-Transform-Width-and-Height-Independently-tp4806... Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.
Just to not think much :) Take a little svg and try to rotate it and show all the steps you took and mistakes you made, until you got it right. Le 27/2/15 01:30, Sean P. DeNigris a écrit :
stepharo wrote
Could you write a little doc on what you learned? I have to think about it. There were a lot of little ahas, but I don't know how to summarize it... The biggest realization was that "canvases + transforms" is extremely powerful!
----- Cheers, Sean -- View this message in context: http://forum.world.st/Canvas-Transform-Width-and-Height-Independently-tp4806... Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.
participants (3)
-
Nicolai Hess -
Sean P. DeNigris -
stepharo