Programming morphs - page 4 - structure
Last updated at 12:11 pm UTC on 12 June 2018
Page 4 shows a large blue morph (a square).
Morphs can be combined into larger morphs. Those larger morphs themselves can be combined into yet larger morphs.
Every visible morph but the World itself has an "owner", which is the morph it is a part of:
joe owner "return joe's owner"
You can add a new morph to an existing morph using addMorph:
ellipse := EllipseMorph new.
ellipse position: joe position.
joe addMorph: ellipse.
Rearrange things using position:
ellipse position: (joe position + (20@20)).
Try dragging the ellipse morph now, using the mouse. You'll notice that whenever you try to grab the ellipse, you will actually grab all of joe. Morphic presents the illusion that the ellipse is no stuck to joe and will follow it around. You can create fairly complicated morphs just by combining existing morphs together with addMorph:.
You can remove morphs using delete:
"joe := Morph new.
joe extent: 100@100.