Form
Last updated at 2:40 pm UTC on 3 October 2020
Form is an important class in Squeak which is used everywhere. It is a subclass of DisplayMedium.
- A form is a rectangular array of pixels, used for holding bitmaps.
- All pictures, including character images (see class StrikeFont and TTCFont) are Forms.
- An instance is created by
- Form fromFileNamed: aFileName
- Form fromDisplay: aRectangle
- Form fromUser
- and other methods
- The class Form reads and writes BMP and JPG files.
- The GIFReadWriter, JPEGReadWriter2 and PNGReadWriter give back instances of Form as well.
- If you send the message #asMorph to a Form object you get an ImageMorph instance.
- form bits gives back the Bitmap
- form bits asArray just the bits as an array
- For further details see class documentation of Form and examples in the examples category. This is a useful starting point for exploring the Squeak Graphics system.
part of the class hierarchy
Object #()
DisplayObject #()
DisplayMedium #()
Form #('bits' 'width' 'height' 'depth' 'offset')
B3DTexture #('wrap' 'interpolate' 'envMode')
ColorForm #('colors' 'cachedDepth' 'cachedColormap')
Cursor #()
CursorWithMask #('maskForm')
DisplayScreen #('clippingBox')
B3DDisplayScreen #()
StaticForm #()
Examples to be executed in Morphic
1.
"http://wiki.squeak.org/squeak/697"
f := Form extent: 5@5 depth: 32.
"f extent 5@5"
"f width 5"
f colorAt: 0@0 put: Color red.
f colorAt: 0@4 put: Color green.
f colorAt: 4@4 put: Color blue.
f colorAt: 4@0 put: Color yellow.
(f magnifyBy: 16) asMorph openInHand.

If you add
InspectorBrowser openOn: f
at the end you get a browser showing the instance variables of the form object together with the methods the object has:

2.
The graphic added under point 1. was done with
Form fromUser asMorph openInWorld
gives you an ImageMorph
See also