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

ブラウザ探検でみつけた面白サンプルコード

back



Formクラスを調べていてメソッド内でみつけたサンプルソースコードです。
こんなところにもサンプルを書いているなんてなんていい人なんだ。
(といっても誰のこと?)
これって何のサンプルなんだろというものや動かないじゃんって物も
抜粋してますのでご了承のほどを。

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




■まずはページエフェクト



--------------------------------------------
Display slideImage: (Form fromDisplay: (40@40 extent: 300@300)) reverse at: 40@40 delta: 3@-4
--------------------------------------------


--------------------------------------------
Display wipeImage: (Form fromDisplay: (40@40 extent: 300@300)) reverse at: 40@40 delta: 0@-2
--------------------------------------------


--------------------------------------------
Display zoomInTo: (Form fromDisplay: (40@40 extent: 300@300)) reverse at: 40@40.
--------------------------------------------


--------------------------------------------
Display zoomOutTo: (Form fromDisplay: (40@40 extent: 300@300)) reverse at: 40@40.
--------------------------------------------



--------------------------------------------
Display zoomInTo: (Form fromDisplay: (40@40 extent: 300@300)) reverse at: 40@40
--------------------------------------------



--------------------------------------------
Display zoomOutTo: (Form fromDisplay: (40@40 extent: 300@300)) reverse at: 40@40
--------------------------------------------



--------------------------------------------
Display fadeImageVert: (Form fromDisplay: (10@10 extent: 300@300)) reverse at: 10@10
--------------------------------------------



--------------------------------------------
Display fadeImageSquares: (Form fromDisplay: (40@40 extent: 300@300)) reverse at: 40@40
--------------------------------------------



--------------------------------------------
Display fadeImageHorFine: (Form fromDisplay: (10@10 extent: 300@300)) reverse at: 10@10
--------------------------------------------



--------------------------------------------
Display fadeImageHor: (Form fromDisplay: (10@10 extent: 300@300)) reverse at: 10@10
--------------------------------------------


エラーが途中で出ちゃうです。
--------------------------------------------
Display fadeImageFine: (Form fromDisplay: (40@40 extent: 300@300)) reverse at: 40@40
--------------------------------------------


エラーが途中で出ちゃうです。
--------------------------------------------
Display fadeImageCoarse: (Form fromDisplay: (40@40 extent: 300@300)) reverse at: 40@40
--------------------------------------------



--------------------------------------------
1 to: 4 do: [:corner | Display pageImage:
				(Form fromDisplay: (10@10 extent: 200@300)) reverse
			at: 10@10 corner: corner]

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



--------------------------------------------
1 to: 4 do: [:corner | Display pageWarp:
				(Form fromDisplay: (10@10 extent: 200@300)) reverse
			at: 10@10 forward: false]

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



■そのほかいろいろ



--------------------------------------------
| f cg |
[Sensor anyButtonPressed] whileFalse:
	[f _ Form fromDisplay: (Sensor cursorPoint extent: 50@50).
	cg _ f cgForPixelValue: (Color black pixelValueForDepth: f depth) orNot: false.
	f displayAt: 0@0.
	Display fill: (cg extent: 2@2) fillColor: Color red].
	ScheduledControllers restore

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



--------------------------------------------
 | f f2 f3 | f _ Form fromUser. f2 _ Form fromDisplay: (0@0 extent: f extent). f3 _ f2 deepCopy.
0.0 to: 1.0 by: 1.0/32 do:
	[:t | f3 _ f2 deepCopy. f3 copyBits: f at: 0@0 translucent: t.
	f3 displayAt: 0@0. (Delay forMilliseconds: 100) wait].

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


--------------------------------------------
((Form extent: 100@100 depth: Display depth)
	fillFromXColorBlock: [:x | Color r: x g: 0.0 b: 0.5]) display

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



--------------------------------------------
 | d |
((Form extent: 100@20 depth: Display depth)
	fillFromXYColorBlock:
	[:x :y | d _ 1.0 - (x - 0.5) abs - (y - 0.5) abs.
	Color r: d g: 0 b: 1.0-d]) display

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



--------------------------------------------
((Form extent: 100@100 depth: Display depth)
	fillFromYColorBlock: [:y | Color r: y g: 0.0 b: 0.5]) display

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



--------------------------------------------
[Sensor anyButtonPressed] whileFalse:
	[((Form fromDisplay: (Sensor cursorPoint extent: 130@66))
			flipBy: #vertical centerAt: 0@0) display]

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



--------------------------------------------
 | f f2 p |
 [Sensor anyButtonPressed] whileFalse:
	[f _ Form fromDisplay: ((p _ Sensor cursorPoint) extent: 31@41).
	Display fillBlack: (p extent: 31@41).
	f2 _ f flipBy: #vertical centerAt: 0@0.
	(f2 flipBy: #vertical centerAt: 0@0) displayAt: p]

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



--------------------------------------------
| f cp | f _ Form fromDisplay: (Rectangle originFromUser: 100@100).
Display restoreAfter: [Sensor waitNoButton.
[Sensor anyButtonPressed] whileFalse:
	[cp _ Sensor cursorPoint.
	(f magnify: f boundingBox by: (cp x asFloat@cp y asFloat)/f extent) display]]

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



--------------------------------------------
 | f f2 p | [Sensor anyButtonPressed] whileFalse:
	[f _ Form fromDisplay: ((p _ Sensor cursorPoint) extent: 31@41).
	Display fillBlack: (p extent: 31@41).
	f2 _ f magnify: f boundingBox by: 5@3.
	(f2 shrink: f2 boundingBox by: 5@3) displayAt: p]

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



--------------------------------------------
[Sensor anyButtonPressed] whileFalse:
       [(Display magnify: (Sensor cursorPoint extent: 131@81) by: 0.5 smoothing: 2) display]

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



--------------------------------------------
| f cp | f _ Form fromDisplay: (Rectangle originFromUser: 100@100).
Display restoreAfter: [Sensor waitNoButton.
[Sensor anyButtonPressed] whileFalse:
       [cp _ Sensor cursorPoint.
        (f magnify: f boundingBox by: (cp x asFloat@cp y asFloat)/f extent smoothing: 2) display]]

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



--------------------------------------------
 | f f2 f3 | f _ Form fromUser. f replaceColor: f preferredColor withColor: Color transparent.
f2 _ Form fromDisplay: (0@0 extent: f extent). f3 _ f2 deepCopy.
0.0 to: 1.0 by: 1.0/32 do:
	[:t | f3 _ f2 deepCopy. f3 paintBits: f at: 0@0 translucent: t.
	f3 displayAt: 0@0. (Delay forMilliseconds: 100) wait].

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



--------------------------------------------
 | f diff | f _ Form fromUser.
[Sensor anyButtonPressed] whileFalse:
	[diff _ f pixelCompare: f boundingBox
		with: Display at: Sensor cursorPoint.
	diff printString , '        ' displayAt: 0@0]

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



--------------------------------------------
 | a f |  f _ Form fromDisplay: (0@0 extent: 200@200).  a _ 0.
[Sensor anyButtonPressed] whileFalse:
	[((Form fromDisplay: (Sensor cursorPoint extent: 130@66))
		rotateBy: (a _ a+5)) display].
f display

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



--------------------------------------------
[Sensor anyButtonPressed] whileFalse:
	[((Form fromDisplay: (Sensor cursorPoint extent: 130@66))
		rotateBy: #left centerAt: 0@0) display]

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



--------------------------------------------
 | f f2 p | [Sensor anyButtonPressed] whileFalse:
	[f _ Form fromDisplay: ((p _ Sensor cursorPoint) extent: 31@41).
	Display fillBlack: (p extent: 31@41).
	f2 _ f rotateBy: #left centerAt: 0@0.
	(f2 rotateBy: #right centerAt: 0@0) displayAt: p]

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



--------------------------------------------
 | a f |  f _ Form fromDisplay: (0@0 extent: 200@200).  a _ 0.
[Sensor anyButtonPressed] whileFalse:
	[((Form fromDisplay: (Sensor cursorPoint extent: 130@66))
		rotateBy: (a _ a+5) magnify: 0.75 smoothing: 2) display].
f display

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



--------------------------------------------
 | a f |  f _ Form fromDisplay: (0@0 extent: 200@200).  a _ 0.
[Sensor anyButtonPressed] whileFalse:
	[((Form fromDisplay: (Sensor cursorPoint extent: 130@66))
		rotateBy: (a _ a+5) smoothing: 2) display].
f display

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



--------------------------------------------
 | r tallies nonZero |
Cursor blank showWhile: [
[Sensor anyButtonPressed] whileFalse:
	[r _ Sensor cursorPoint extent: 10@10.
	Display border: (r expandBy: 2) width: 2 rule: Form reverse fillColor: nil.
	tallies _ (Display copy: r) tallyPixelValues.
	nonZero _ (1 to: tallies size) select: [:i | (tallies at: i) > 0]
			thenCollect: [:i | (tallies at: i) -> (i-1)].
	nonZero printString , '          ' displayAt: 0@0.
	Display border: (r expandBy: 2) width: 2 rule: Form reverse fillColor: nil]]

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



--------------------------------------------
| r tallies nonZero |
Cursor blank showWhile: [
[Sensor anyButtonPressed] whileFalse:
	[r _ Sensor cursorPoint extent: 10@10.
	Display border: (r expandBy: 2) width: 2 rule: Form reverse fillColor: nil.
	tallies _ (Display copy: r) tallyPixelValues.
	nonZero _ (1 to: tallies size) select: [:i | (tallies at: i) > 0]
			thenCollect: [:i | (tallies at: i) -> (i-1)].
	nonZero printString , '          ' displayAt: 0@0.
	Display border: (r expandBy: 2) width: 2 rule: Form reverse fillColor: nil]]

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






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


Thursday, 29 September 2005, 2:49:51 pm
| r tallies nonZero |
Cursor blank showWhile: [
[Sensor anyButtonPressed] whileFalse:
[r _ Sensor cursorPoint extent: 10@10.
Display border: (r expandBy: 2) width: 2 rule: Form reverse fillColor: nil.
tallies _ (Display copy: r) tallyPixelValues.
nonZero _ (1 to: tallies size) select: [:i | (tallies at: i) > 0]
thenCollect: [:i | (tallies at: i) -> (i-1)].
nonZero printString , ' ' displayAt: 0@0.
Display border: (r expandBy: 2) width: 2 rule: Form reverse fillColor: nil]]

Links to this Page