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.
Files changed (94) hide show
  1. data/ChangeLog +254 -234
  2. data/History.txt +6 -0
  3. data/Manifest.txt +10 -0
  4. data/Rakefile +27 -7
  5. data/examples/cocoa1-basic.rb +14 -14
  6. data/examples/cocoa10-transparent.rb +26 -26
  7. data/examples/cocoa11-application.rb +13 -13
  8. data/examples/cocoa2-draw.rb +23 -23
  9. data/examples/cocoa3-affine.rb +29 -29
  10. data/examples/cocoa4-font.rb +24 -24
  11. data/examples/cocoa5-image.rb +22 -22
  12. data/examples/cocoa6-sound.rb +24 -24
  13. data/examples/cocoa7-movie.rb +40 -40
  14. data/examples/cocoa8-movieoverlay.rb +42 -42
  15. data/examples/cocoa9-streaming.rb +40 -40
  16. data/examples/opengl1-basic.rb +14 -14
  17. data/examples/opengl11-application.rb +13 -13
  18. data/examples/opengl2-draw.rb +23 -23
  19. data/examples/opengl3-affine.rb +29 -29
  20. data/examples/sample1.rb +11 -11
  21. data/examples/sample10.rb +16 -16
  22. data/examples/sample11.rb +22 -22
  23. data/examples/sample11a.rb +33 -33
  24. data/examples/sample12.rb +30 -30
  25. data/examples/sample12a.rb +35 -35
  26. data/examples/sample13.rb +116 -116
  27. data/examples/sample15.rb +24 -24
  28. data/examples/sample16.rb +31 -31
  29. data/examples/sample16a.rb +35 -35
  30. data/examples/sample6.rb +18 -18
  31. data/examples/sample7.rb +16 -16
  32. data/examples/sample9.rb +20 -20
  33. data/examples/testgl.rb +169 -169
  34. data/lib/sgl/bass.rb +46 -46
  35. data/lib/sgl/cocoa-app.rb +43 -43
  36. data/lib/sgl/cocoa-color.rb +65 -65
  37. data/lib/sgl/cocoa-draw.rb +72 -72
  38. data/lib/sgl/cocoa-event.rb +229 -229
  39. data/lib/sgl/cocoa-media.rb +144 -144
  40. data/lib/sgl/cocoa-notuse.rb +493 -493
  41. data/lib/sgl/cocoa-window.rb +203 -203
  42. data/lib/sgl/cocoa.rb +8 -8
  43. data/lib/sgl/opengl-app.rb +38 -38
  44. data/lib/sgl/opengl-color.rb +44 -44
  45. data/lib/sgl/opengl-draw.rb +260 -260
  46. data/lib/sgl/opengl-event.rb +325 -325
  47. data/lib/sgl/opengl-modules.rb +22 -22
  48. data/lib/sgl/opengl-window.rb +224 -224
  49. data/lib/sgl/opengl.rb +7 -7
  50. data/lib/sgl/sgl-button.rb +135 -135
  51. data/lib/sgl/sgl-client.rb +21 -21
  52. data/lib/sgl/sgl-color.rb +68 -82
  53. data/lib/sgl/sgl-connect.rb +9 -9
  54. data/lib/sgl/sgl-server.rb +58 -58
  55. data/lib/sgl/sgl-spring.rb +216 -216
  56. data/lib/sgl/version.rb +2 -2
  57. data/scripts/lib-txt2html.rb +130 -0
  58. data/scripts/txt2html +2 -63
  59. data/spec/sgl_spec.rb +13 -0
  60. data/spec/spec.opts +1 -0
  61. data/spec/spec_helper.rb +1 -0
  62. data/test/test_cocoa_app.rb +291 -291
  63. data/test/test_module_ruby16.rb +30 -30
  64. data/test/test_opengl_app.rb +147 -147
  65. data/test/test_opengl_basic.rb +22 -22
  66. data/test/test_opengl_fullscreen.rb +23 -23
  67. data/test/test_opengl_novice.rb +35 -35
  68. data/website/challenge1.html +91 -91
  69. data/website/challenge1.txt +3 -3
  70. data/website/challenge2.html +143 -144
  71. data/website/challenge2.txt +13 -14
  72. data/website/challenge3.html +66 -63
  73. data/website/challenge3.txt +7 -7
  74. data/website/cocoa.html +85 -88
  75. data/website/cocoa.txt +2 -4
  76. data/website/description.html +138 -138
  77. data/website/description.txt +1 -1
  78. data/website/exercise1.html +262 -264
  79. data/website/exercise1.txt +58 -53
  80. data/website/exercise2.html +241 -683
  81. data/website/exercise2.txt +11 -427
  82. data/website/exercise3.html +206 -0
  83. data/website/exercise3.txt +155 -0
  84. data/website/exercise4.html +198 -0
  85. data/website/exercise4.txt +151 -0
  86. data/website/exercise5.html +162 -0
  87. data/website/exercise5.txt +113 -0
  88. data/website/exhibition.html +84 -84
  89. data/website/howto.html +146 -134
  90. data/website/howto.txt +9 -0
  91. data/website/index.html +178 -178
  92. data/website/index.txt +20 -19
  93. data/website/sound.html +141 -141
  94. metadata +16 -3
data/History.txt CHANGED
@@ -1,4 +1,10 @@
1
+ == 0.4.0 2007-06-25
2
+
3
+ * 1 major enhancement:
4
+ * Sound function.
5
+
1
6
  == 0.3.1 2007-06-19
2
7
 
3
8
  * 0 major enhancement:
4
9
  * Initial release
10
+
data/Manifest.txt CHANGED
@@ -69,9 +69,13 @@ lib/sgl/sgl-spring.rb
69
69
  lib/sgl/sgl-timer.rb
70
70
  lib/sgl/sgl.rb
71
71
  lib/sgl/version.rb
72
+ scripts/lib-txt2html.rb
72
73
  scripts/makemanifest.rb
73
74
  scripts/txt2html
74
75
  setup.rb
76
+ spec/sgl_spec.rb
77
+ spec/spec.opts
78
+ spec/spec_helper.rb
75
79
  test/test_bass.rb
76
80
  test/test_cocoa_app.rb
77
81
  test/test_helper.rb
@@ -96,6 +100,12 @@ website/exercise1.html
96
100
  website/exercise1.txt
97
101
  website/exercise2.html
98
102
  website/exercise2.txt
103
+ website/exercise3.html
104
+ website/exercise3.txt
105
+ website/exercise4.html
106
+ website/exercise4.txt
107
+ website/exercise5.html
108
+ website/exercise5.txt
99
109
  website/exhibition.html
100
110
  website/exhibition.txt
101
111
  website/howto.html
data/Rakefile CHANGED
@@ -8,12 +8,19 @@ require 'rake/rdoctask'
8
8
  require 'rake/contrib/rubyforgepublisher'
9
9
  require 'fileutils'
10
10
  require 'hoe'
11
+ begin
12
+ require 'spec/rake/spectask'
13
+ rescue LoadError
14
+ puts 'To use rspec for testing you must install rspec gem:'
15
+ puts '$ sudo gem install rspec'
16
+ exit
17
+ end
11
18
 
12
19
  include FileUtils
13
20
  require File.join(File.dirname(__FILE__), 'lib', 'sgl', 'version')
14
21
 
15
22
  AUTHOR = 'Kouichirou Eto'
16
- EMAIL = "eto at rubyforge dot org"
23
+ EMAIL = "eto _at_ rubyforge _dot_ org"
17
24
  DESCRIPTION = '"sgl: simple generic library" enables you to create a program with graphics and sound easily.'
18
25
  GEM_NAME = 'sgl'
19
26
 
@@ -84,8 +91,11 @@ hoe.remote_rdoc_dir = File.join(PATH.gsub(/^#{RUBYFORGE_PROJECT}\/?/,''), 'rdoc'
84
91
 
85
92
  desc 'Generate website files'
86
93
  task :website_generate do
94
+ require 'scripts/lib-txt2html'
95
+ t2h = Txt2Html.new
87
96
  Dir['website/**/*.txt'].each do |txt|
88
- sh %{ ruby scripts/txt2html #{txt} > #{txt.gsub(/txt$/,'html')} }
97
+ puts txt
98
+ t2h.translate(txt, txt.gsub(/txt$/, 'html'))
89
99
  end
90
100
  end
91
101
 
@@ -128,6 +138,13 @@ task :check_version do
128
138
  end
129
139
  end
130
140
 
141
+ desc "Run the specs under spec/models"
142
+ Spec::Rake::SpecTask.new do |t|
143
+ t.spec_opts = ['--options', "spec/spec.opts"]
144
+ t.spec_files = FileList['spec/*_spec.rb']
145
+ t.libs << "lib"
146
+ end
147
+
131
148
  # add chmod.
132
149
  task :docs do
133
150
  sh %{ chmod -R go+rx doc }
@@ -161,11 +178,12 @@ desc 'Change mode to erase executable bits.'
161
178
  task :chmod do
162
179
  sh "chmod 644 Rakefile ChangeLog"
163
180
  sh "chmod 644 *.txt */*.txt"
164
- sh "chmod 644 */*.html"
165
- sh "chmod 644 */*.rhtml"
166
- sh "chmod 644 */*/*.js"
167
- sh "chmod 644 */*/*.css"
181
+ sh "chmod 644 */*.html"
182
+ sh "chmod 644 */*.rhtml"
183
+ sh "chmod 644 */*/*.js"
184
+ sh "chmod 644 */*/*.css"
168
185
  sh "chmod 644 *.rb */*.rb */*/*.rb"
186
+ sh "chmod 644 */*.opts"
169
187
  sh "chmod 755 scripts/*"
170
188
  end
171
189
 
@@ -188,6 +206,8 @@ end
188
206
 
189
207
  # Add tasks to gem
190
208
  task :gem => [:manifest]
191
- #task :gem => [:website_generate]
192
209
 
210
+ #desc "Default task is to run specs"
211
+ task :default => [:spec]
212
+ #task :default => :spec
193
213
  #task :default => :test
@@ -1,14 +1,14 @@
1
- #!/usr/bin/env ruby
2
- # Copyright (C) 2004-2007 Kouichirou Eto, All rights reserved.
3
-
4
- require "sgl/cocoa"
5
-
6
- def setup
7
- window 100, 100
8
- end
9
-
10
- def display
11
- line 0, 0, 100, 100
12
- end
13
-
14
- mainloop
1
+ #!/usr/bin/env ruby
2
+ # Copyright (C) 2004-2007 Kouichirou Eto, All rights reserved.
3
+
4
+ require "sgl/cocoa"
5
+
6
+ def setup
7
+ window 100, 100
8
+ end
9
+
10
+ def display
11
+ line 0, 0, 100, 100
12
+ end
13
+
14
+ mainloop
@@ -1,26 +1,26 @@
1
- #!/usr/bin/env ruby
2
- # Copyright (C) 2004-2007 Kouichirou Eto, All rights reserved.
3
-
4
- require "sgl/cocoa"
5
-
6
- def setup
7
- $windowBorder = 0
8
- $windowShadow = 0
9
- window 700, 700
10
- backgroundHSV 66, 100, 20, 100
11
- end
12
-
13
- def display
14
- x, y = mouseX, mouseY
15
- colorHSV 0, 50, 100
16
- backgroundHSV 66, 100, 20, y/7
17
- lineWidth 3
18
- line 0, 0, x, y
19
- line 700, 0, x, y
20
- line 0, 700, x, y
21
- line 700, 700, x, y
22
- colorHSV 0, 100, 100
23
- rect x-10, y-10, x+10, y+10
24
- end
25
-
26
- mainloop
1
+ #!/usr/bin/env ruby
2
+ # Copyright (C) 2004-2007 Kouichirou Eto, All rights reserved.
3
+
4
+ require "sgl/cocoa"
5
+
6
+ def setup
7
+ $windowBorder = 0
8
+ $windowShadow = 0
9
+ window 700, 700
10
+ backgroundHSV 66, 100, 20, 100
11
+ end
12
+
13
+ def display
14
+ x, y = mouseX, mouseY
15
+ colorHSV 0, 50, 100
16
+ backgroundHSV 66, 100, 20, y/7
17
+ lineWidth 3
18
+ line 0, 0, x, y
19
+ line 700, 0, x, y
20
+ line 0, 700, x, y
21
+ line 700, 700, x, y
22
+ colorHSV 0, 100, 100
23
+ rect x-10, y-10, x+10, y+10
24
+ end
25
+
26
+ mainloop
@@ -1,13 +1,13 @@
1
- #!/usr/bin/env ruby
2
- # Copyright (C) 2004-2007 Kouichirou Eto, All rights reserved.
3
-
4
- require "sgl/cocoa-app"
5
-
6
- app = SGL::Application.new
7
- app.set_setup {
8
- app.window(100, 100)
9
- }
10
- app.set_display {
11
- app.line(0, 0, 100, 100)
12
- }
13
- app.mainloop
1
+ #!/usr/bin/env ruby
2
+ # Copyright (C) 2004-2007 Kouichirou Eto, All rights reserved.
3
+
4
+ require "sgl/cocoa-app"
5
+
6
+ app = SGL::Application.new
7
+ app.set_setup {
8
+ app.window(100, 100)
9
+ }
10
+ app.set_display {
11
+ app.line(0, 0, 100, 100)
12
+ }
13
+ app.mainloop
@@ -1,23 +1,23 @@
1
- #!/usr/bin/env ruby
2
- # Copyright (C) 2004-2007 Kouichirou Eto, All rights reserved.
3
-
4
- require "sgl/cocoa"
5
-
6
- def setup
7
- window 300, 300
8
- backgroundHSV 66, 100, 20
9
- end
10
-
11
- def display
12
- x, y = mouseX, mouseY
13
- colorHSV 0, 50, 100
14
- lineWidth 3
15
- line 0, 0, x, y
16
- line 300, 0, x, y
17
- line 0, 300, x, y
18
- line 300, 300, x, y
19
- colorHSV 0, 100, 100
20
- rect x-10, y-10, x+10, y+10
21
- end
22
-
23
- mainloop
1
+ #!/usr/bin/env ruby
2
+ # Copyright (C) 2004-2007 Kouichirou Eto, All rights reserved.
3
+
4
+ require "sgl/cocoa"
5
+
6
+ def setup
7
+ window 300, 300
8
+ backgroundHSV 66, 100, 20
9
+ end
10
+
11
+ def display
12
+ x, y = mouseX, mouseY
13
+ colorHSV 0, 50, 100
14
+ lineWidth 3
15
+ line 0, 0, x, y
16
+ line 300, 0, x, y
17
+ line 0, 300, x, y
18
+ line 300, 300, x, y
19
+ colorHSV 0, 100, 100
20
+ rect x-10, y-10, x+10, y+10
21
+ end
22
+
23
+ mainloop
@@ -1,29 +1,29 @@
1
- #!/usr/bin/env ruby
2
- # Copyright (C) 2004-2007 Kouichirou Eto, All rights reserved.
3
-
4
- require "sgl/cocoa"
5
-
6
- def setup
7
- window 700, 700
8
- backgroundHSV 66, 100, 20
9
- $font1 = font("Helvetica", 25)
10
- end
11
-
12
- def display
13
- x, y = mouseX, mouseY
14
- colorHSV 0, 50, 100
15
- lineWidth 3
16
- line 0, 0, x, y
17
- line 700, 0, x, y
18
- line 0, 700, x, y
19
- line 700, 700, x, y
20
- colorHSV 0, 100, 100
21
-
22
- translate x, y
23
- rotateZ y
24
- colorHSV y, 100, 100
25
- $font1.text(10, 10, "hello")
26
- rect -10, -10, +10, +10
27
- end
28
-
29
- mainloop
1
+ #!/usr/bin/env ruby
2
+ # Copyright (C) 2004-2007 Kouichirou Eto, All rights reserved.
3
+
4
+ require "sgl/cocoa"
5
+
6
+ def setup
7
+ window 700, 700
8
+ backgroundHSV 66, 100, 20
9
+ $font1 = font("Helvetica", 25)
10
+ end
11
+
12
+ def display
13
+ x, y = mouseX, mouseY
14
+ colorHSV 0, 50, 100
15
+ lineWidth 3
16
+ line 0, 0, x, y
17
+ line 700, 0, x, y
18
+ line 0, 700, x, y
19
+ line 700, 700, x, y
20
+ colorHSV 0, 100, 100
21
+
22
+ translate x, y
23
+ rotateZ y
24
+ colorHSV y, 100, 100
25
+ $font1.text(10, 10, "hello")
26
+ rect -10, -10, +10, +10
27
+ end
28
+
29
+ mainloop
@@ -1,24 +1,24 @@
1
- #!/usr/bin/env ruby
2
- # Copyright (C) 2004-2007 Kouichirou Eto, All rights reserved.
3
-
4
- require "sgl/cocoa"
5
-
6
- def setup
7
- window 700, 700
8
- backgroundHSV 66, 100, 20
9
- $font1 = font("Helvetica")
10
- $font2 = font("GothicMB101Pro-Ultra")
11
- # $font.show_all
12
- # $font.show_fixed
13
- end
14
-
15
- def display
16
- x, y = mouseX, mouseY
17
- colorHSV 0, 50, 100, y/3
18
- $font1.size = x
19
- $font1.text(x, y, "hello")
20
- $font2.size = y
21
- $font2.text(x-50, y-50, "����")
22
- end
23
-
24
- mainloop
1
+ #!/usr/bin/env ruby
2
+ # Copyright (C) 2004-2007 Kouichirou Eto, All rights reserved.
3
+
4
+ require "sgl/cocoa"
5
+
6
+ def setup
7
+ window 700, 700
8
+ backgroundHSV 66, 100, 20
9
+ $font1 = font("Helvetica")
10
+ $font2 = font("GothicMB101Pro-Ultra")
11
+ # $font.show_all
12
+ # $font.show_fixed
13
+ end
14
+
15
+ def display
16
+ x, y = mouseX, mouseY
17
+ colorHSV 0, 50, 100, y/3
18
+ $font1.size = x
19
+ $font1.text(x, y, "hello")
20
+ $font2.size = y
21
+ $font2.text(x-50, y-50, "����")
22
+ end
23
+
24
+ mainloop
@@ -1,22 +1,22 @@
1
- #!/usr/bin/env ruby
2
- # Copyright (C) 2004-2007 Kouichirou Eto, All rights reserved.
3
-
4
- require "sgl/cocoa"
5
-
6
- def setup
7
- $windowShadow = 0
8
- window 700, 700
9
- backgroundHSV 66, 100, 20
10
- $image = image("../media/image-heart.psd")
11
- end
12
-
13
- def display
14
- x, y = mouseX, mouseY
15
- colorHSV 0, 50, 100, y/5
16
- backgroundHSV 66, 100, 20, 300-x/2
17
- $image.rect(100, 100, 200, 200)
18
- $image.rect(0, 0, x, y)
19
- $image.rect(x, y, x+100, y+100)
20
- end
21
-
22
- mainloop
1
+ #!/usr/bin/env ruby
2
+ # Copyright (C) 2004-2007 Kouichirou Eto, All rights reserved.
3
+
4
+ require "sgl/cocoa"
5
+
6
+ def setup
7
+ $windowShadow = 0
8
+ window 700, 700
9
+ backgroundHSV 66, 100, 20
10
+ $image = image("../media/image-heart.psd")
11
+ end
12
+
13
+ def display
14
+ x, y = mouseX, mouseY
15
+ colorHSV 0, 50, 100, y/5
16
+ backgroundHSV 66, 100, 20, 300-x/2
17
+ $image.rect(100, 100, 200, 200)
18
+ $image.rect(0, 0, x, y)
19
+ $image.rect(x, y, x+100, y+100)
20
+ end
21
+
22
+ mainloop
@@ -1,24 +1,24 @@
1
- #!/usr/bin/env ruby
2
- # Copyright (C) 2004-2007 Kouichirou Eto, All rights reserved.
3
-
4
- require "sgl/cocoa"
5
-
6
- def setup
7
- window 700, 700
8
- backgroundHSV 66, 100, 20
9
- $sound = sound("../media/Pop.aiff")
10
- end
11
-
12
- def onMouseDown(x, y)
13
- if 100 < x && x < 120 && 100 < y && y < 120
14
- $sound.play
15
- end
16
- end
17
-
18
- def display
19
- x, y = mouseX, mouseY
20
- color 100, 0, 0
21
- rect 100, 100, 120, 120
22
- end
23
-
24
- mainloop
1
+ #!/usr/bin/env ruby
2
+ # Copyright (C) 2004-2007 Kouichirou Eto, All rights reserved.
3
+
4
+ require "sgl/cocoa"
5
+
6
+ def setup
7
+ window 700, 700
8
+ backgroundHSV 66, 100, 20
9
+ $sound = sound("../media/Pop.aiff")
10
+ end
11
+
12
+ def onMouseDown(x, y)
13
+ if 100 < x && x < 120 && 100 < y && y < 120
14
+ $sound.play
15
+ end
16
+ end
17
+
18
+ def display
19
+ x, y = mouseX, mouseY
20
+ color 100, 0, 0
21
+ rect 100, 100, 120, 120
22
+ end
23
+
24
+ mainloop