Morphic

Morphic is a graphics system which uses graphical objects called Morphs for simplified GUI-building. It was originally developed by Randy Smith and John Maloney (a Scratch Team member and Squeak developer) for the programming language Self, but later rewritten in Squeak.

Morphic Inheritance

Morphic systems have an interesting inheritance system: a morph can inherit from another, improving on the parent. Morphic inheritance begins at the root class Morph. Each Morph is a subclass of Morph either directly or indirectly. For example, the hypothetical ResizeHandleMorph is a subclass of DraggableObjectMorph which is a subclass of Morph.

An example of inheritance

A hypothetical inheritance of Morphs is shown below:

Morph
            CompoundMorph  (contains  many  Morphs)
                        FrameMorph  (rectangular  frame,  resizable  and  draggable)
                                    WorldMorph  (contains  all  other  Morphs)
                        WindowMorph  (graphical  window)
            DraggableMorph  (is  draggable)
                        ResizeHandleMorph
                                    WindowResizeHandleMorph  (for  windows)
                        SliderMorph
                                    VerticalSliderMorph
                                    HorizontalSliderMorph
                                    ScrollBarMorph
                                                VerticalScrollBarMorph
                                                HorizontalScrollBarMorph
                        WindowTopBarMorph
            ButtonMorph
                        CancelButtonMorph
            TextBoxMorph
                        NumberOnlyTextBoxMorph

Inheritance is used to either improve upon a morph or specialize it for some purpose. The base Morphs should have lots of simple functionality which is then used by higher-level Morphs, which reduces code redundancy.

Morphic.js

Morphic.js is a Morphic environment written entirely in JavaScript using only the HTML5 Canvas APIs. It was created by Jens Mönig for BYOB 4.0 (a.k.a Snap!), but has found other uses on the website, such as the HTML Viewer, now JsScratch. Morphic.js was inspired by the Squeak Morphic system.

Some help can be found here.

Creating Morphs in Squeak

Via Code

A morph is a special form of a generic Class, but it is a subclass of Morph rather than Object (root class). To open a new Morph, use the code (for a BouncingAtomsMorph):

BouncingAtomsMorph new openInWorld.

To create customized morphs, see Squeak Tutorial: Morphic classes.

Via GUI editing

To access the Scratch Morphs, one must first use the Shift-Click R method and turn fill screen off.

Open the World menu and pick the choice labeled "new morph..."

Clicking on that option then opens the "Add a new morph" menu. This has a list of all subclasses of Morph on which if you click, you get an instance of that morph to place anywhere on the World.

See Also

  • This page was last modified on 14 February 2014, at 05:22.