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

Hilaire Fernandes hfern at free.fr
Sun Mar 3 03:39:55 PST 2024


Hi Ian,

It is so cool to read about people developing stuff with Cuis. I hope 
you will continue to do so, Cuis-Smalltalk is a very pleasant system to 
explore and to develop new ideas.

On the issue you reported related to the scaled Morph moving out of 
sight, which I am not 100% sure to understand, I don't master well 
subtle English; I think it is related to the fact that the scaleBy: use 
as a center the origin of the scaled Morph. For the record the scale is 
a homothety[1] geometric transformation and its requires two parameters: 
the scaling factor and a point, the center of the homothety. By default, 
in Cuis, this last one is set as the origin of the Morph coordinates system.

Take an example, the two same Morph rectangles defined with points:

  * (0 ; 0) (6 ; 0) (6 ; 2) (0 ; 2)
  * (-3 ; -1) (3 ; -1) (3 ; 1) (-3 ; 1)

In the first rectangle, the origin in the Morph coordinates system is 
the top left point, in the second rectangle it is the center of the 
Rectangle (intersection of its two diagonals)

When scaling, the first one is scaled from the its top left summit; the 
second one is scaled from the center of the rectangle. It will result in 
two different rectangles.

Filein the source file included in this message and execute in a 
Workspace the code below:

|rect1 rect2 |
rect1  :=  Rectangle1Morph  new  openInWorld.
rect2  :=  Rectangle2Morph  new  openInWorld.
rect1  morphPosition:  DisplayScreen  actualScreenSize  //  2  -  (60 at 20)."needed adjustment because different origin"
rect2  morphPosition:  DisplayScreen  actualScreenSize  //  2.
rect1  scaleBy:  2.
rect2  scaleBy:  2.

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

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.

Hilaire


[1] https://en.wikipedia.org/wiki/Homothety

-- 
GNU Dr. Geo
http://gnu.org/s/dr-geo/
http://gnu-drgeo.blogspot.com/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cuis.st/mailman/archives/cuis-dev/attachments/20240303/e892966d/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: IanJeffries.st
Type: application/vnd.sailingtracker.track
Size: 905 bytes
Desc: not available
URL: <http://lists.cuis.st/mailman/archives/cuis-dev/attachments/20240303/e892966d/attachment.st>


More information about the Cuis-dev mailing list