OBY12
ってことで修正するです。パート2
顔の形を変えるメソッドもちょっと変更するです。っていうか、これが事の発端だったわけね。
Obyクラスのメソッドだった「rectangleFace」,「sketchFace」,「polygonFace」,「ellipseFace」を今度は
ObyFaceクラスのメソッドにします。
■ObyFaceクラスにメソッドを追加
● rectangleFaceメソッド
基本的にはObyクラスのものとおなじです。
--------------------------------------------
rectangleFace
| s c |
"現在の顔のサイズと色を取得"
s _ face extent.
c _ face color.
"現在の顔を削除"
face delete.
"顔の生成"
face _ RectangleMorph new.
face extent: s.
face borderWidth: 1.
face color: c.
self addMorphBack: face.
face align: face center with: self center.
--------------------------------------------
アクセプト。
Alt + s ( Cmd + s )
● sketchFaceメソッド
基本的にはObyクラスのものとおなじです。
--------------------------------------------
sketchFace
"現在の顔を削除"
face delete.
"顔の生成"
face _ SketchMorph new.
self addMorphBack: face.
face align: face center with: self center.
--------------------------------------------
アクセプト。
Alt + s ( Cmd + s )
● polygonFaceメソッド
基本的にはObyクラスのものとおなじです。
--------------------------------------------
polygonFace
| s c |
"現在の顔のサイズと色を取得"
s _ face extent.
c _ face color.
"現在の顔を削除"
face delete.
"顔の生成"
face _ PolygonMorph new.
face setVertices: (Array with: 0@0 with: (s x)@0 with: (s x // 2)@(s y)).
face borderWidth: 1.
face borderColor: Color black.
face color: c.
self addMorphBack: face.
face align: face center with: self center.
--------------------------------------------
アクセプト。
Alt + s ( Cmd + s )
● ellipseFaceメソッド
基本的にはObyクラスのものとおなじです。
--------------------------------------------
ellipseFace
| s c |
"現在の顔のサイズと色を取得"
s _ face extent.
c _ face color.
"現在の顔を削除"
face delete.
"顔の生成"
face _ EllipseMorph new.
face extent: s.
face borderWidth: 1.
face color: c.
self addMorphBack: face.
face align: face center with: self center.
--------------------------------------------
アクセプト。
Alt + s ( Cmd + s )
■Obyクラスのメソッドを修正
ObyクラスからはObyFaceクラスの同じ名前のメソッドを呼び出すだけね。
● rectangleFaceメソッド
--------------------------------------------
rectangleFace
face rectangleFace.
--------------------------------------------
アクセプト。
Alt + s ( Cmd + s )
● sketchFaceメソッド
--------------------------------------------
sketchFace
face sketchFace.
--------------------------------------------
アクセプト。
Alt + s ( Cmd + s )
● polygonFaceメソッド
--------------------------------------------
polygonFace
face polygonFace.
--------------------------------------------
アクセプト。
Alt + s ( Cmd + s )
● ellipseFaceメソッド
--------------------------------------------
ellipseFace
face ellipseFace.
--------------------------------------------
アクセプト。
Alt + s ( Cmd + s )
★インスタンスで実際に試してみる
--------------------------------------------
oby new openInWorld.
--------------------------------------------
Alt + d ( Cmd + d )
--------------------------------------------
oby rectangleFace.
--------------------------------------------
Alt + d ( Cmd + d )
--------------------------------------------
oby sketchFace.
--------------------------------------------
Alt + d ( Cmd + d )
--------------------------------------------
oby polygonFace.
--------------------------------------------
Alt + d ( Cmd + d )
--------------------------------------------
oby ellipseFace
--------------------------------------------
Alt + d ( Cmd + d )
ちなみに元の楕円に戻したはずなのに大きさが小さくなってるのは
スケッチにしたときにサイズが変わっちゃったからなのね。
とりあえずここまでのソースコードでござる。
ObyMorph.st
▲PREV ------ ● TOP ● ------ NEXT▼
■ MEMO ■
Links to this Page
- I BOBY last edited on 28 April 2004 at 8:57:55 pm by tk0005-202x210x196x109.ap-TK.usen.ad.jp
- OBY11 last edited on 17 June 2007 at 7:14:26 am by localhost.localdomain
- OBY13 last edited on 17 June 2007 at 7:06:10 am by localhost.localdomain