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

落書きで遊ぶ

back


落書きで遊ぶです。おいらは「落書きを飛ばす」ってのがお気に入り。


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




■ 落書きする

画面に落書きでする。
--------------------------------------------
| fd lastPt nextPt |

[Sensor anyButtonPressed] whileFalse.
fd _ FormCanvas on: Display.
lastPt _ Sensor cursorPoint.
[Sensor anyButtonPressed] whileTrue:[
	nextPt _ Sensor cursorPoint.
	nextPt = lastPt ifFalse:[
		fd line: lastPt to: nextPt width: 5 color: Color black.
		lastPt _ nextPt.
	].
].

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




■ 落書きする(シンメトリー) 

シンメトリーに落書きしまする。
--------------------------------------------
| fd lastPt nextPt lastPt2 dx dy |

[Sensor anyButtonPressed] whileFalse.
fd _ FormCanvas on: Display.
lastPt _ Sensor cursorPoint.
lastPt2 _ lastPt.
[Sensor anyButtonPressed] whileTrue:[
	nextPt _ Sensor cursorPoint.
	nextPt = lastPt ifFalse:[
		fd line: lastPt to: nextPt width: 5 color: Color random.
		dx _ (nextPt x - lastPt x) negated .
		dy _ (nextPt y - lastPt y) .
		nextPt2 _ lastPt2 + (dx@dy).
		fd line: lastPt2 to: nextPt2 width: 5 color: Color random.
		lastPt _ nextPt.
		lastPt2 _ nextPt2.
	].
].

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




■ 落書きを壁紙にする 

落書きしたものを壁紙にします。
(3行目を省略するとすけた部分がへんてこになるです。涙)
--------------------------------------------
| fc col fd pts lastPt nextPt minX minY maxX maxY rect fc2 |

fc _ FormCanvas extent: Display extent.
fc fillColor: Color white.
col _ Color random.
[Sensor anyButtonPressed] whileFalse.
fd _ FormCanvas on: Display.
pts _ OrderedCollection new.
lastPt _ Sensor cursorPoint.
pts add: lastPt.
[Sensor anyButtonPressed] whileTrue:[
	nextPt _ Sensor cursorPoint.
	nextPt = lastPt ifFalse:[
		fd line: lastPt to: nextPt width: 5 color: col.
		fc line: (lastPt) to: (nextPt) width: 5 color: col.
		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).
fc2 form setAsBackground.

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


きっと目がチカチカしてうるさいと思うんで
これをdo itして白地の部分を選ぶとすっきりするでする。
--------------------------------------------
(Form fromUser) setAsBackground
--------------------------------------------


■ 落書きをスケッチモーフにする

落書きしたものをスケッチモーフにするです。
--------------------------------------------
| fc col fd pts lastPt nextPt minX minY maxX maxY rect fc2 sk |

fc _ FormCanvas extent: Display extent.
col _ Color random.
[Sensor anyButtonPressed] whileFalse.
fd _ FormCanvas on: Display.
pts _ OrderedCollection new.
lastPt _ Sensor cursorPoint.
pts add: lastPt.
[Sensor anyButtonPressed] whileTrue:[
	nextPt _ Sensor cursorPoint.
	nextPt = lastPt ifFalse:[
		fd line: lastPt to: nextPt width: 5 color: col.
		fc line: (lastPt) to: (nextPt) width: 5 color: col.
		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).
sk _ SketchMorph withForm: fc2 form.
sk openInWorld.
sk position: (minX@minY) - (5@5).

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




■ 落書きを飛ばす

落書きしたものを画面の外に飛ばしまする。
いろんな方向に直線を描いてみてちょ。(とびます!とびます!)
--------------------------------------------
| fc col fd pts lastPt nextPt minX minY maxX maxY rect fc2 sk angle |

fc _ FormCanvas extent: Display extent.
col _ Color random.
[Sensor anyButtonPressed] whileFalse.
fd _ FormCanvas on: Display.
pts _ OrderedCollection new.
lastPt _ Sensor cursorPoint.
pts add: lastPt.
[Sensor anyButtonPressed] whileTrue:[
	nextPt _ Sensor cursorPoint.
	nextPt = lastPt ifFalse:[
		fd line: lastPt to: nextPt width: 5 color: col.
		fc line: (lastPt) to: (nextPt) width: 5 color: col.
		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).
sk _ SketchMorph withForm: fc2 form.
sk openInWorld.
sk position: (minX@minY) - (5@5).
[[sk bounds intersects: ActiveWorld bounds] whileTrue: [
	(Delay forMilliseconds: 10) wait.
	angle _ (pts first - pts last) degrees.
	sk position: sk position + (Point r: 10 degrees: angle). 
	].
sk delete.
] fork.

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




■ 落書きを飛ばしたり回転させたり

落書きするとき小さく描くか、スタートポイントとエンドポイントを近ずけると回転しまする。
--------------------------------------------
| fc col fd pts lastPt nextPt minX minY maxX maxY rect fc2 sk d |

fc _ FormCanvas extent: Display extent.
col _ Color random.
[Sensor anyButtonPressed] whileFalse.
fd _ FormCanvas on: Display.
pts _ OrderedCollection new.
lastPt _ Sensor cursorPoint.
pts add: lastPt.
[Sensor anyButtonPressed] whileTrue:[
	nextPt _ Sensor cursorPoint.
	nextPt = lastPt ifFalse:[
		fd line: lastPt to: nextPt width: 5 color: col.
		fc line: (lastPt) to: (nextPt) width: 5 color: col.
		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).
sk _ SketchMorph withForm: fc2 form.
sk openInWorld.
sk position: (minX@minY) - (5@5).
d _ (pts last - pts first) abs.
[[sk bounds intersects: ActiveWorld bounds] whileTrue: [
	(Delay forMilliseconds: 30) wait.
	d < (50@50) 
		ifTrue: [
			sk heading: sk heading + 10]
		ifFalse: [angle _ (pts first - pts last) degrees.
				sk position: sk position + (Point r: 10 degrees: angle)].
	].
	sk delete
] fork.

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







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


Link to this Page