View this PageEdit this PageAttachments to this PageHistory of this PageHomeRecent ChangesSearch the SwikiHelp Guide

落書きアニメーションで遊ぶ

back


「落書きを飛ばす」をアニメーションするようにしたです。


ソースコードを順番にドゥ〜イットしてみてください。
Alt + d ( Cmd + d )




左マウスドラッグすると青の色の線で落書きできます。
もう一度左マウスドラッグすると赤の線で落書きできます。
右クリックで初めに描いた線と次に描いた線を交互に表示しながら
落書きが飛んでいきます。

(ちょっとソースが長いけど全部選択してドゥ〜イットしてちょんまげ。
--------------------------------------------
| fc fc2 fc3 fd pts cnt col lastPt nextPt minX minY maxX maxY rect sk angle |

fc _ FormCanvas extent: Display extent.
fd _ FormCanvas on: Display.
pts _ OrderedCollection new.
cnt _ 1.
col _ Color red.
[Sensor yellowButtonPressed] whileFalse: [
	Sensor waitButton.
	(cnt <= 2) ifTrue: [
	lastPt _ Sensor cursorPoint.
	pts add: lastPt.
	[Sensor redButtonPressed] whileTrue:[
		nextPt _ Sensor cursorPoint.
		nextPt = lastPt ifFalse:[
			fd line: lastPt to: nextPt width: 5 color: col.
			fc line: (lastPt) to: (nextPt) width: 5 color: Color black.
			pts add: nextPt.
			lastPt _ nextPt]].
	minX _ pts inject: (pts at: 1) x into: [:m :p | m min: p x] .
	minY _ pts inject: (pts at: 1) y into: [:m :p | m min: p y] .
	maxX _ pts inject: 0 into: [:m :p | m max: p x] .
	maxY _ pts inject: 0 into: [:m :p | m max: p y] .
	rect _ (minX@minY) corner: (maxX@maxY).
	fc2 _ FormCanvas extent: (maxX - minX) @ (maxY - minY).
	fc2 _ fc form copy: (rect expandBy: 5).
	cnt = 1 ifTrue: [
		fc3 _ FormCanvas extent: fc2 extent.
		fc3 _ fc2 form copy: fc2 boundingBox.
		fc fillColor: transpalent.
		col _ Color blue].
	cnt _ cnt + 1]].
sk _ SketchMorph withForm: fc3 form.
sk openInWorld.
sk position: (minX@minY) - (5@5).
[[sk bounds intersects: ActiveWorld bounds] whileTrue: [
	(Delay forMilliseconds: 60) wait.
	angle _ (pts first - pts last) degrees.
	sk position: sk position + (Point r: 10 degrees: angle). 
	sk form: fc2 form.
	(Delay forMilliseconds: 60) wait.
	angle _ (pts first - pts last) degrees.
	sk position: sk position + (Point r: 10 degrees: angle). 
	sk form: fc3 form.
	].
sk delete.
] fork.

--------------------------------------------




下の入力ボックスに書き込んで”add to the page”ボタンで登録出来ます。
修正したい場合はページ左のアイコンの”edit”で出てくる画面で編集可能です。
ページ左のアイコンの”uploads”で画像(JPEG,GIF,PNG)のアップロードもできます。


Link to this Page