トップ 最新

GREEN HARMONY 手記

2020年04月08日 smalltalkでプログラミング20200408 [長年日記]

smalltalkプログラミング

Squeak Workspaceにて実行

| fm pen colorList angle arr parr w |
colorList := #('#9370DB' 'red' 'orange' 'yellow' 'green' 'blue'
 '#000080' '#800080' '#808000').
fm := Form extent: 500@500 depth: Display depth.
fm fillColor: Color white.
pen := Pen newOnForm: fm.
w := 20.
pen defaultNib: w.
pen place: 160@330.
parr :=
	 {
	0@0 .
	-1@ -1 .
	-1@1 .
	1@1 .
	1@0 .
	0@ -2 .
	-2@0 .
	0@ 2 .
	2@1 .
	1@ -3 .
	-3@ -1 .
	-1@3
	}.
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)*(w@w))).
	pen turn: angle.
	arr do: [:n |
		pen color: (Color fromString: (colorList at:n)).
		pen go: w.
		
	].
	pen color: (Color fromString: 'white').
	pen go:w.
	arr := arr collect: [:n |  n * 2 - 1 \\ 9 + 1]. 
].
fm asMorph openInWorld