sgl 0.4.0 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/ChangeLog +254 -234
- data/History.txt +6 -0
- data/Manifest.txt +10 -0
- data/Rakefile +27 -7
- data/examples/cocoa1-basic.rb +14 -14
- data/examples/cocoa10-transparent.rb +26 -26
- data/examples/cocoa11-application.rb +13 -13
- data/examples/cocoa2-draw.rb +23 -23
- data/examples/cocoa3-affine.rb +29 -29
- data/examples/cocoa4-font.rb +24 -24
- data/examples/cocoa5-image.rb +22 -22
- data/examples/cocoa6-sound.rb +24 -24
- data/examples/cocoa7-movie.rb +40 -40
- data/examples/cocoa8-movieoverlay.rb +42 -42
- data/examples/cocoa9-streaming.rb +40 -40
- data/examples/opengl1-basic.rb +14 -14
- data/examples/opengl11-application.rb +13 -13
- data/examples/opengl2-draw.rb +23 -23
- data/examples/opengl3-affine.rb +29 -29
- data/examples/sample1.rb +11 -11
- data/examples/sample10.rb +16 -16
- data/examples/sample11.rb +22 -22
- data/examples/sample11a.rb +33 -33
- data/examples/sample12.rb +30 -30
- data/examples/sample12a.rb +35 -35
- data/examples/sample13.rb +116 -116
- data/examples/sample15.rb +24 -24
- data/examples/sample16.rb +31 -31
- data/examples/sample16a.rb +35 -35
- data/examples/sample6.rb +18 -18
- data/examples/sample7.rb +16 -16
- data/examples/sample9.rb +20 -20
- data/examples/testgl.rb +169 -169
- data/lib/sgl/bass.rb +46 -46
- data/lib/sgl/cocoa-app.rb +43 -43
- data/lib/sgl/cocoa-color.rb +65 -65
- data/lib/sgl/cocoa-draw.rb +72 -72
- data/lib/sgl/cocoa-event.rb +229 -229
- data/lib/sgl/cocoa-media.rb +144 -144
- data/lib/sgl/cocoa-notuse.rb +493 -493
- data/lib/sgl/cocoa-window.rb +203 -203
- data/lib/sgl/cocoa.rb +8 -8
- data/lib/sgl/opengl-app.rb +38 -38
- data/lib/sgl/opengl-color.rb +44 -44
- data/lib/sgl/opengl-draw.rb +260 -260
- data/lib/sgl/opengl-event.rb +325 -325
- data/lib/sgl/opengl-modules.rb +22 -22
- data/lib/sgl/opengl-window.rb +224 -224
- data/lib/sgl/opengl.rb +7 -7
- data/lib/sgl/sgl-button.rb +135 -135
- data/lib/sgl/sgl-client.rb +21 -21
- data/lib/sgl/sgl-color.rb +68 -82
- data/lib/sgl/sgl-connect.rb +9 -9
- data/lib/sgl/sgl-server.rb +58 -58
- data/lib/sgl/sgl-spring.rb +216 -216
- data/lib/sgl/version.rb +2 -2
- data/scripts/lib-txt2html.rb +130 -0
- data/scripts/txt2html +2 -63
- data/spec/sgl_spec.rb +13 -0
- data/spec/spec.opts +1 -0
- data/spec/spec_helper.rb +1 -0
- data/test/test_cocoa_app.rb +291 -291
- data/test/test_module_ruby16.rb +30 -30
- data/test/test_opengl_app.rb +147 -147
- data/test/test_opengl_basic.rb +22 -22
- data/test/test_opengl_fullscreen.rb +23 -23
- data/test/test_opengl_novice.rb +35 -35
- data/website/challenge1.html +91 -91
- data/website/challenge1.txt +3 -3
- data/website/challenge2.html +143 -144
- data/website/challenge2.txt +13 -14
- data/website/challenge3.html +66 -63
- data/website/challenge3.txt +7 -7
- data/website/cocoa.html +85 -88
- data/website/cocoa.txt +2 -4
- data/website/description.html +138 -138
- data/website/description.txt +1 -1
- data/website/exercise1.html +262 -264
- data/website/exercise1.txt +58 -53
- data/website/exercise2.html +241 -683
- data/website/exercise2.txt +11 -427
- data/website/exercise3.html +206 -0
- data/website/exercise3.txt +155 -0
- data/website/exercise4.html +198 -0
- data/website/exercise4.txt +151 -0
- data/website/exercise5.html +162 -0
- data/website/exercise5.txt +113 -0
- data/website/exhibition.html +84 -84
- data/website/howto.html +146 -134
- data/website/howto.txt +9 -0
- data/website/index.html +178 -178
- data/website/index.txt +20 -19
- data/website/sound.html +141 -141
- metadata +16 -3
data/website/description.txt
CHANGED
data/website/exercise1.html
CHANGED
@@ -1,264 +1,262 @@
|
|
1
|
-
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
2
|
-
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
3
|
-
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
4
|
-
<head>
|
5
|
-
<link rel="stylesheet" href="stylesheets/screen.css" type="text/css" media="screen" />
|
6
|
-
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
7
|
-
<title>
|
8
|
-
練習問題
|
9
|
-
</title>
|
10
|
-
<script src="javascripts/rounded_corners_lite.inc.js" type="text/javascript"></script>
|
11
|
-
<style>
|
12
|
-
|
13
|
-
</style>
|
14
|
-
<script type="text/javascript">
|
15
|
-
window.onload = function() {
|
16
|
-
settings = {
|
17
|
-
tl: { radius: 10 },
|
18
|
-
tr: { radius: 10 },
|
19
|
-
bl: { radius: 10 },
|
20
|
-
br: { radius: 10 },
|
21
|
-
antiAlias: true,
|
22
|
-
autoPad: true,
|
23
|
-
validTags: ["div"]
|
24
|
-
}
|
25
|
-
var versionBox = new curvyCorners(settings, document.getElementById("version"));
|
26
|
-
versionBox.applyCornersToAll();
|
27
|
-
}
|
28
|
-
</script>
|
29
|
-
</head>
|
30
|
-
<body>
|
31
|
-
<div id="main">
|
32
|
-
|
33
|
-
<h1>練習問題
|
34
|
-
<div id="version" class="clickable" onclick='document.location = "http://rubyforge.org/projects/sgl"; return false'>
|
35
|
-
<p>Get Version</p>
|
36
|
-
<a href="http://rubyforge.org/projects/sgl" class="numbers">0.
|
37
|
-
</div>
|
38
|
-
<h2>課題1
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
<
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
end
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
<
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
</
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
</body>
|
264
|
-
</html>
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
2
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
3
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
4
|
+
<head>
|
5
|
+
<link rel="stylesheet" href="stylesheets/screen.css" type="text/css" media="screen" />
|
6
|
+
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
7
|
+
<title>
|
8
|
+
練習問題1
|
9
|
+
</title>
|
10
|
+
<script src="javascripts/rounded_corners_lite.inc.js" type="text/javascript"></script>
|
11
|
+
<style>
|
12
|
+
|
13
|
+
</style>
|
14
|
+
<script type="text/javascript">
|
15
|
+
window.onload = function() {
|
16
|
+
settings = {
|
17
|
+
tl: { radius: 10 },
|
18
|
+
tr: { radius: 10 },
|
19
|
+
bl: { radius: 10 },
|
20
|
+
br: { radius: 10 },
|
21
|
+
antiAlias: true,
|
22
|
+
autoPad: true,
|
23
|
+
validTags: ["div"]
|
24
|
+
}
|
25
|
+
var versionBox = new curvyCorners(settings, document.getElementById("version"));
|
26
|
+
versionBox.applyCornersToAll();
|
27
|
+
}
|
28
|
+
</script>
|
29
|
+
</head>
|
30
|
+
<body>
|
31
|
+
<div id="main">
|
32
|
+
|
33
|
+
<h1>練習問題1</h1>
|
34
|
+
<div id="version" class="clickable" onclick='document.location = "http://rubyforge.org/projects/sgl"; return false'>
|
35
|
+
<p>Get Version</p>
|
36
|
+
<a href="http://rubyforge.org/projects/sgl" class="numbers">1.0.0</a>
|
37
|
+
</div>
|
38
|
+
<h2>課題1: 一本の線を描く</h2>
|
39
|
+
|
40
|
+
|
41
|
+
<pre syntax="ruby">
|
42
|
+
# kadai1.rb
|
43
|
+
require 'sgl' # プログラムの最初に必ず書く必要がある
|
44
|
+
window 100, 100 # windowを開く
|
45
|
+
background 0 # 背景を黒にする
|
46
|
+
color 100 # 描画する色を白にする
|
47
|
+
line 0, 0, 100, 100 # 左下から右上に線を描く
|
48
|
+
wait # そのまま待つ
|
49
|
+
</pre>
|
50
|
+
|
51
|
+
<h2>課題2: ある考えの元に3本の線を描く</h2>
|
52
|
+
|
53
|
+
|
54
|
+
<pre syntax="ruby">
|
55
|
+
# kadai2.rb
|
56
|
+
require 'sgl'
|
57
|
+
window 100, 100
|
58
|
+
background 0
|
59
|
+
color 100
|
60
|
+
line 0, 0, 100, 100
|
61
|
+
line 0, 0, 100, 50
|
62
|
+
line 0, 0, 100, 25
|
63
|
+
wait
|
64
|
+
</pre>
|
65
|
+
|
66
|
+
<h2>課題3: 5本以下の直線で「変化」を表現する</h2>
|
67
|
+
|
68
|
+
|
69
|
+
<pre syntax="ruby">
|
70
|
+
# kadai3.rb
|
71
|
+
# 考えてみましょう.
|
72
|
+
</pre>
|
73
|
+
|
74
|
+
<h2>課題4: 10本以下の直線で「ハーモニー(調和)」を表現する</h2>
|
75
|
+
|
76
|
+
|
77
|
+
<pre syntax="ruby">
|
78
|
+
# kadai4.rb
|
79
|
+
# 考えてみましょう.
|
80
|
+
</pre>
|
81
|
+
|
82
|
+
<h2>課題5: 一つの変数を使って2本の直線の構成をコントロールする</h2>
|
83
|
+
|
84
|
+
|
85
|
+
<pre syntax="ruby">
|
86
|
+
# kadai5.rb
|
87
|
+
require 'sgl'
|
88
|
+
window 100, 100
|
89
|
+
a = 50
|
90
|
+
line 0, 0, 50, a
|
91
|
+
line 100, 0, 50, a
|
92
|
+
wait
|
93
|
+
</pre>
|
94
|
+
|
95
|
+
<h2>課題6: 繰り返しを使った形態を描く</h2>
|
96
|
+
|
97
|
+
|
98
|
+
<pre syntax="ruby">
|
99
|
+
# kadai6.rb
|
100
|
+
require 'sgl'
|
101
|
+
window 100, 100
|
102
|
+
for a in 20..80
|
103
|
+
color a
|
104
|
+
line a, 0, a, 100
|
105
|
+
end
|
106
|
+
wait
|
107
|
+
</pre>
|
108
|
+
|
109
|
+
<h2>課題7: 計算を使った形態を描く</h2>
|
110
|
+
|
111
|
+
|
112
|
+
<pre syntax="ruby">
|
113
|
+
# kadai7.rb
|
114
|
+
require 'sgl'
|
115
|
+
window 100, 100
|
116
|
+
for a in 20..40
|
117
|
+
color a
|
118
|
+
line(a, 0, a*2, 100)
|
119
|
+
end
|
120
|
+
wait
|
121
|
+
</pre>
|
122
|
+
|
123
|
+
<h2>課題8: 半透明を使った形態を描く</h2>
|
124
|
+
|
125
|
+
|
126
|
+
<pre syntax="ruby">
|
127
|
+
# kadai8.rb
|
128
|
+
require 'sgl'
|
129
|
+
window 100,100
|
130
|
+
color 100, 0, 0 # 赤
|
131
|
+
rect 10,10,70,70 # 四角
|
132
|
+
color 0,0,100,50 # 半透明の青
|
133
|
+
rect 30,30,90,90 # 四角を重ねてかく
|
134
|
+
wait
|
135
|
+
</pre>
|
136
|
+
|
137
|
+
<h2>課題9: 入れ子構造,格子状にひろがる形態を作る</h2>
|
138
|
+
|
139
|
+
|
140
|
+
<pre syntax="ruby">
|
141
|
+
# kadai9.rb
|
142
|
+
require 'sgl'
|
143
|
+
window 200,200
|
144
|
+
for a in 0..10
|
145
|
+
for b in 0..10
|
146
|
+
color a*10, b*10, b*10
|
147
|
+
rect a*20+5, b*20+5, a*20+15, b*20+15
|
148
|
+
end
|
149
|
+
end
|
150
|
+
wait
|
151
|
+
</pre>
|
152
|
+
|
153
|
+
<h2>課題10: 条件分岐,画面の左右で違う形態を描く</h2>
|
154
|
+
|
155
|
+
|
156
|
+
<pre syntax="ruby">
|
157
|
+
# kadai10.rb
|
158
|
+
require 'sgl'
|
159
|
+
window 200,200
|
160
|
+
for a in 0..200
|
161
|
+
color a/2, 50, 50
|
162
|
+
if a < 100
|
163
|
+
line a, 50, a, 100
|
164
|
+
else
|
165
|
+
line a, 100, a, 150
|
166
|
+
end
|
167
|
+
end
|
168
|
+
wait
|
169
|
+
</pre>
|
170
|
+
|
171
|
+
<h2>課題11: 自分なりの命令を作り,それを用いた形態を描く</h2>
|
172
|
+
|
173
|
+
|
174
|
+
<pre syntax="ruby">
|
175
|
+
# kadai11.rb
|
176
|
+
require 'sgl'
|
177
|
+
window 100,100
|
178
|
+
background 100
|
179
|
+
|
180
|
+
def my_rect(x1, y1, x2, y2, outline, fill)
|
181
|
+
color fill
|
182
|
+
rect x1, y1, x2, y2
|
183
|
+
color outline
|
184
|
+
line x1, y1, x2, y1
|
185
|
+
line x2, y1, x2, y2
|
186
|
+
line x2, y2, x1, y2
|
187
|
+
line x1, y2, x1, y1
|
188
|
+
end
|
189
|
+
|
190
|
+
my_rect(20, 20, 40, 30, 20, 50)
|
191
|
+
my_rect(60, 60, 80, 90, 70, 90)
|
192
|
+
wait
|
193
|
+
</pre>
|
194
|
+
|
195
|
+
<p>defというコマンドで命令を定義する.ここでは,枠付きの塗りつぶされた四
|
196
|
+
角形を定義している.defの後に続くのが命令の名前となる.アルファベット
|
197
|
+
の小文字から始まっている必要がある.</p>
|
198
|
+
|
199
|
+
|
200
|
+
<h2>課題12: flipを使ってアニメーションを作る</h2>
|
201
|
+
|
202
|
+
|
203
|
+
<pre syntax="ruby">
|
204
|
+
# kadai12.rb
|
205
|
+
require 'sgl'
|
206
|
+
window 100,100
|
207
|
+
loop do
|
208
|
+
for a in 0..100
|
209
|
+
line 20,a,80,a
|
210
|
+
flip
|
211
|
+
end
|
212
|
+
end
|
213
|
+
wait
|
214
|
+
</pre>
|
215
|
+
|
216
|
+
<p>flipというところで,ちょうど紙をめくるように次の画面を表示させている.
|
217
|
+
<code>loop do 〜〜〜 end</code> で,その間を無限に繰り返す.</p>
|
218
|
+
|
219
|
+
|
220
|
+
<h2>課題13: <span class="caps">HSV</span>による色指定を使り,自分なりの色グラデーションを作る</h2>
|
221
|
+
|
222
|
+
|
223
|
+
<p>静止画でもアニメーションでもよい.(colorHSV, backgroundHSV)</p>
|
224
|
+
|
225
|
+
|
226
|
+
<pre syntax="ruby">
|
227
|
+
# kadai13.rb
|
228
|
+
require 'sgl'
|
229
|
+
window 100,100
|
230
|
+
background 100
|
231
|
+
|
232
|
+
loop do
|
233
|
+
for h in 0..100
|
234
|
+
colorHSV h, 50, 100
|
235
|
+
rect 0, h, 100, h+5
|
236
|
+
flip
|
237
|
+
end
|
238
|
+
end
|
239
|
+
wait
|
240
|
+
</pre>
|
241
|
+
|
242
|
+
<ul>
|
243
|
+
<li>colorHSV(h, s, v) → hue, saturation, value</li>
|
244
|
+
<li>hue → 色調</li>
|
245
|
+
<li>saturation → どれだけ原色に近いか</li>
|
246
|
+
<li>value → 明るさ</li>
|
247
|
+
</ul>
|
248
|
+
|
249
|
+
|
250
|
+
<ul>
|
251
|
+
<li>4番目のパラメーターを使って,透明度を設定することもできる.</li>
|
252
|
+
<li>backgroundHSVというコマンドもある.</li>
|
253
|
+
</ul>
|
254
|
+
<p class="coda">
|
255
|
+
30th June 2007<br>
|
256
|
+
</p>
|
257
|
+
</div>
|
258
|
+
|
259
|
+
<!-- insert site tracking codes here, like Google Urchin -->
|
260
|
+
|
261
|
+
</body>
|
262
|
+
</html>
|