GREEN HARMONY 手記
2020年04月10日 smalltalkでプログラミング20200410 [長年日記]
☆ smalltalkプログラミング
Squeak Workspaceにて実行
| fm pen ft colorList angle arr parr | colorList := #('#9370DB' 'red' 'orange' 'yellow' 'green' 'blue' '#000080' '#800080' '#808000'). fm := Form extent: 300@300 depth: Display depth. fm fillColor: Color white. pen := Pen newOnForm: fm. pen defaultNib: 1. ft := StrikeFont familyName: #Atlanta pointSize: 30. pen place: 100@180. parr := {0@0 . 5@ -5 . -5@ -5 . -5@5 . 5@20 . 20@ -20 . -20@ -20 . -20@20 . 20@35 . 35@ -35. -35@ -35 . -35@35 }. arr := #(9 1 2 3 4 5 6 7 8). angle := 90. 1 to: 12 do: [:i | i = 2 ifTrue: [ angle := -90]. pen place: (pen location + parr at: i). pen turn: angle. arr do: [:n | pen color: (Color fromString: (colorList at:n)). pen print: n asString withFont: ft. ]. arr := arr collect: [:n | n * 2 - 1 \\ 9 + 1]. ]. fm asMorph openInWorld