Wednesday, December 2, 2009

Morphic

I moved on to the chapter on morphic projects. I skipped over quite a few chapters on the way but the tutorial is pretty good about making sense no matter which point you start from. This chapter if considerably more interesting than the class creation. The code for creating morphs looks something like this

s := 'WEEEEEEEEEE!' asMorph openInWorld "Opens a string object on the screen which can be manipulated in the same way as any other morph"
s openViewerForArgument "Opens a screen used for manipulating the weee string"
joe := Morph new color: Color blue. "Defines joe as a blue morph which is by default a rectangle"
joe openInWorld.
bill := Morph new color: Color red .
bill openInWorld.
joe position:(joe position + (15@-5)) "Changes the position of joe by (15, -5)
joe extent:(joe extent*1.1)
joe color: Color orange
joe color: (Color blue alpha: 0.5)
bill color: (Color red alpha: 0.5) "Makes bill transparent and red"
bill extent:(bill extent*1.1)

1 comment:

  1. Nice post! Keep exploring on your own until Winter break. After we come back, I'd like to give you a set of "traditional" CS programs to write and see how easy it is for you to write them in Squeak.

    ReplyDelete