[Cuis-dev] [ANN] Cuis-Smalltalk-RoadTrip idle game + a question on implementing a ZoomPanMorph

Hilaire Fernandes hfern at free.fr
Sun Mar 3 04:15:01 PST 2024

Le 03/03/2024 à 12:39, Hilaire Fernandes a écrit :
> Affine transformations should be used and composed with translations 
> and scale but I can't get a code snipped working yet. You could then 
> extent your morph with the appropriate protocol.

Here it is with the proper composed affine transformations to get the 
scaling with the center that suit you. The scaling is done around the 
point v:

|rect1 rect2 transformation v |
v  :=  60 at 20.
rect1  :=  Rectangle1Morph  new  openInWorld.
rect2  :=  Rectangle2Morph  new  openInWorld.
rect1  morphPosition:  DisplayScreen  actualScreenSize  //  2  -  v.
rect2  morphPosition:  DisplayScreen  actualScreenSize  //  2.
transformation  :=  rect1  location  composedWith:  (
	(AffineTransformation  withTranslation:  v)composedWith:  		
		((AffineTransformation  withScale:  2)composedWith:  	
			(AffineTransformation  withTranslation:  v  negated)) ).	
rect1  location:  transformation.
rect2  scaleBy:  2.

Rectangle1Morph allInstancesDo: [:each | each delete].
Rectangle2Morph allInstancesDo: [:each | each delete].

Observe the scaled blue and pink rectangles are at now at the same position.


GNU Dr. Geo
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cuis.st/mailman/archives/cuis-dev/attachments/20240303/4c99bf3d/attachment-0001.htm>

More information about the Cuis-dev mailing list