devil 0.1.9.1 → 0.1.9.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,26 +1,26 @@
1
- $direc = File.dirname(__FILE__)
2
-
3
- $LOAD_PATH.push("#{$direc}/../lib/")
4
-
5
- require 'rubygems'
6
- require 'devil/gosu'
7
-
8
- class W < Gosu::Window
9
- def initialize
10
- super(1024, 768, false, 20)
11
-
12
- @img = Gosu::Image.new(self, "tank.png")
13
- @img.circle 100, 100, 50, :color => :purple, :filled => true
14
-
15
- @img.save("tank-modified.png")
16
- end
17
-
18
- def draw
19
- @img.draw 100, 50,1
20
- end
21
-
22
- end
23
-
24
- w = W.new
25
- w.show
26
-
1
+ $direc = File.dirname(__FILE__)
2
+
3
+ $LOAD_PATH.push("#{$direc}/../lib/")
4
+
5
+ require 'rubygems'
6
+ require 'devil/gosu'
7
+
8
+ class W < Gosu::Window
9
+ def initialize
10
+ super(1024, 768, false, 20)
11
+
12
+ @img = Gosu::Image.new(self, "tank.png")
13
+ @img.circle 100, 100, 50, :color => :purple, :filled => true
14
+
15
+ @img.save("tank-modified.png")
16
+ end
17
+
18
+ def draw
19
+ @img.draw 100, 50,1
20
+ end
21
+
22
+ end
23
+
24
+ w = W.new
25
+ w.show
26
+
@@ -1,10 +1,10 @@
1
- $direc = File.dirname(__FILE__)
2
-
3
- $LOAD_PATH.push("#{$direc}/../lib/")
4
-
5
- require 'rubygems'
6
- require 'devil/gosu'
7
-
8
- Devil.load_image("texture.png").emboss.show(512, 400)
9
- Devil.load_image("tank.png").show(300, 400)
10
-
1
+ $direc = File.dirname(__FILE__)
2
+
3
+ $LOAD_PATH.push("#{$direc}/../lib/")
4
+
5
+ require 'rubygems'
6
+ require 'devil/gosu'
7
+
8
+ Devil.load_image("texture.png").emboss.show(512, 400)
9
+ Devil.load_image("tank.png").show(300, 400)
10
+
@@ -1,18 +1,18 @@
1
- $direc = File.dirname(__FILE__)
2
-
3
- $LOAD_PATH.push("#{$direc}/../lib/")
4
-
5
- require 'rubygems'
6
- require 'devil/gosu'
7
-
8
- Devil.with_group("#{$direc}/texture.png", "#{$direc}/red.png") do |img, img2|
9
-
10
- img.blit img2, 100, 100, :crop => [0, 0, img2.width / 2, img2.height / 2]
11
- img.show
12
- end
13
-
14
-
15
-
16
-
17
-
18
-
1
+ $direc = File.dirname(__FILE__)
2
+
3
+ $LOAD_PATH.push("#{$direc}/../lib/")
4
+
5
+ require 'rubygems'
6
+ require 'devil/gosu'
7
+
8
+ Devil.with_group("#{$direc}/texture.png", "#{$direc}/red.png") do |img, img2|
9
+
10
+ img.blit img2, 100, 100, :crop => [0, 0, img2.width / 2, img2.height / 2]
11
+ img.show
12
+ end
13
+
14
+
15
+
16
+
17
+
18
+
@@ -1,95 +1,95 @@
1
- # this test is a hold over from the original ruby-devil bindings (by Jaroslaw Tworek)
2
-
3
- $direc = File.dirname(__FILE__)
4
-
5
- $LOAD_PATH.push("#{$direc}/../lib/")
6
-
7
- require 'rubygems'
8
- require 'glut'
9
- require 'opengl'
10
- require 'devil'
11
- require 'thread'
12
-
13
- $tex_id = 0
14
-
15
- $idle = proc {
16
- GLUT.PostRedisplay
17
- }
18
-
19
- $display = proc {
20
- GL.Clear(GL::COLOR_BUFFER_BIT | GL::DEPTH_BUFFER_BIT)
21
- GL.LoadIdentity
22
- GLU.LookAt(0,0,-5,0,0,0,0,1,0)
23
-
24
- GL.Begin GL::QUADS
25
-
26
-
27
- GL.TexCoord(1,0)
28
- GL.Vertex(1, 1,0)
29
- GL.TexCoord(1,1)
30
- GL.Vertex(1, -1,0)
31
- GL.TexCoord(0,1)
32
- GL.Vertex(-1, -1,0)
33
- GL.TexCoord(0,0)
34
- GL.Vertex(-1, 1,0)
35
-
36
- GL.End
37
-
38
- GLUT.SwapBuffers
39
- }
40
-
41
- $reshape = proc { |w,h|
42
- GL.Viewport(0,0,w,h)
43
- GL.MatrixMode(GL::PROJECTION)
44
- GL.LoadIdentity
45
- GLU.Perspective(45.0, Float(w)/h, 0.01, 100)
46
- GL.MatrixMode(GL::MODELVIEW)
47
- GL.LoadIdentity
48
- }
49
-
50
- def setup_gl
51
- GL.ClearColor( 0,0,0,1)
52
- IL.Init
53
- ILUT.Renderer(ILUT::OPENGL)
54
- GL.Enable(GL::DEPTH_TEST)
55
- GL.DrawBuffer(GL::BACK)
56
- GL.Disable(GL::CULL_FACE)
57
- GL.ShadeModel(GL::FLAT)
58
- GL.Enable(GL::TEXTURE_2D)
59
-
60
- name = IL.GenImages(1)[0]
61
- IL.BindImage(name)
62
-
63
- if File.directory?("test") then
64
- if !File.exist?("test/texture.png") then
65
- raise RuntimeError, "File test/texture.png doesn't exist"
66
- end
67
- IL.LoadImage("test/texture.png")
68
- else
69
- if !File.exist?("texture.png") then
70
- raise RuntimeError, "File texture.png doesn't exist"
71
- end
72
- IL.LoadImage("texture.png")
73
- end
74
-
75
- $tex_id = ILUT.GLBindMipmaps()
76
- IL.DeleteImages([name])
77
-
78
-
79
- end
80
-
81
- def main
82
- GLUT.Init
83
- GLUT.InitDisplayMode(GLUT::DOUBLE | GLUT::RGB | GLUT::DEPTH)
84
- GLUT.InitWindowSize(800,600)
85
- GLUT.CreateWindow("Ruby-DevIL test")
86
- setup_gl
87
- GLUT.DisplayFunc($display)
88
- GLUT.ReshapeFunc($reshape)
89
- GLUT.IdleFunc($idle)
90
- GLUT.MainLoop
91
-
92
-
93
- end
94
-
95
- main
1
+ # this test is a hold over from the original ruby-devil bindings (by Jaroslaw Tworek)
2
+
3
+ $direc = File.dirname(__FILE__)
4
+
5
+ $LOAD_PATH.push("#{$direc}/../lib/")
6
+
7
+ require 'rubygems'
8
+ require 'glut'
9
+ require 'opengl'
10
+ require 'devil'
11
+ require 'thread'
12
+
13
+ $tex_id = 0
14
+
15
+ $idle = proc {
16
+ GLUT.PostRedisplay
17
+ }
18
+
19
+ $display = proc {
20
+ GL.Clear(GL::COLOR_BUFFER_BIT | GL::DEPTH_BUFFER_BIT)
21
+ GL.LoadIdentity
22
+ GLU.LookAt(0,0,-5,0,0,0,0,1,0)
23
+
24
+ GL.Begin GL::QUADS
25
+
26
+
27
+ GL.TexCoord(1,0)
28
+ GL.Vertex(1, 1,0)
29
+ GL.TexCoord(1,1)
30
+ GL.Vertex(1, -1,0)
31
+ GL.TexCoord(0,1)
32
+ GL.Vertex(-1, -1,0)
33
+ GL.TexCoord(0,0)
34
+ GL.Vertex(-1, 1,0)
35
+
36
+ GL.End
37
+
38
+ GLUT.SwapBuffers
39
+ }
40
+
41
+ $reshape = proc { |w,h|
42
+ GL.Viewport(0,0,w,h)
43
+ GL.MatrixMode(GL::PROJECTION)
44
+ GL.LoadIdentity
45
+ GLU.Perspective(45.0, Float(w)/h, 0.01, 100)
46
+ GL.MatrixMode(GL::MODELVIEW)
47
+ GL.LoadIdentity
48
+ }
49
+
50
+ def setup_gl
51
+ GL.ClearColor( 0,0,0,1)
52
+ IL.Init
53
+ ILUT.Renderer(ILUT::OPENGL)
54
+ GL.Enable(GL::DEPTH_TEST)
55
+ GL.DrawBuffer(GL::BACK)
56
+ GL.Disable(GL::CULL_FACE)
57
+ GL.ShadeModel(GL::FLAT)
58
+ GL.Enable(GL::TEXTURE_2D)
59
+
60
+ name = IL.GenImages(1)[0]
61
+ IL.BindImage(name)
62
+
63
+ if File.directory?("test") then
64
+ if !File.exist?("test/texture.png") then
65
+ raise RuntimeError, "File test/texture.png doesn't exist"
66
+ end
67
+ IL.LoadImage("test/texture.png")
68
+ else
69
+ if !File.exist?("texture.png") then
70
+ raise RuntimeError, "File texture.png doesn't exist"
71
+ end
72
+ IL.LoadImage("texture.png")
73
+ end
74
+
75
+ $tex_id = ILUT.GLBindMipmaps()
76
+ IL.DeleteImages([name])
77
+
78
+
79
+ end
80
+
81
+ def main
82
+ GLUT.Init
83
+ GLUT.InitDisplayMode(GLUT::DOUBLE | GLUT::RGB | GLUT::DEPTH)
84
+ GLUT.InitWindowSize(800,600)
85
+ GLUT.CreateWindow("Ruby-DevIL test")
86
+ setup_gl
87
+ GLUT.DisplayFunc($display)
88
+ GLUT.ReshapeFunc($reshape)
89
+ GLUT.IdleFunc($idle)
90
+ GLUT.MainLoop
91
+
92
+
93
+ end
94
+
95
+ main
@@ -1,28 +1,28 @@
1
- $direc = File.dirname(__FILE__)
2
-
3
- $LOAD_PATH.push("#{$direc}/../lib/")
4
-
5
- require 'rubygems'
6
- require "devil"
7
-
8
- Devil.with_image("#{$direc}/texture.png") do |img|
9
- img.pixelize(10)
10
- img.save("#{$direc}/texture_blocky.png")
11
- img.free
12
- end
13
-
14
- img = Devil.load_image("#{$direc}/texture.png")
15
- bink = Devil.load_image("#{$direc}/texture.png")
16
-
17
- img.gamma_correct(1.6)
18
- bink.resize(50, 50)
19
-
20
- img.save("#{$direc}/texture_gamma.png").free
21
- bink.save("#{$direc}/texture_tiny.png").free
22
-
23
-
24
-
25
-
26
-
27
-
28
-
1
+ $direc = File.dirname(__FILE__)
2
+
3
+ $LOAD_PATH.push("#{$direc}/../lib/")
4
+
5
+ require 'rubygems'
6
+ require "devil"
7
+
8
+ Devil.with_image("#{$direc}/texture.png") do |img|
9
+ img.pixelize(10)
10
+ img.save("#{$direc}/texture_blocky.png")
11
+ img.free
12
+ end
13
+
14
+ img = Devil.load_image("#{$direc}/texture.png")
15
+ bink = Devil.load_image("#{$direc}/texture.png")
16
+
17
+ img.gamma_correct(1.6)
18
+ bink.resize(50, 50)
19
+
20
+ img.save("#{$direc}/texture_gamma.png").free
21
+ bink.save("#{$direc}/texture_tiny.png").free
22
+
23
+
24
+
25
+
26
+
27
+
28
+
@@ -1,8 +1,8 @@
1
- $direc = File.dirname(__FILE__)
2
-
3
- $LOAD_PATH.push("#{$direc}/../lib/")
4
-
5
- require 'rubygems'
6
- require 'devil/gosu'
7
-
8
- Devil.load("texture.png", :inprofile => "sRGB.icm", :out_profile => "AdobeRGB1998.icc").save("texture_out.png").free
1
+ $direc = File.dirname(__FILE__)
2
+
3
+ $LOAD_PATH.push("#{$direc}/../lib/")
4
+
5
+ require 'rubygems'
6
+ require 'devil/gosu'
7
+
8
+ Devil.load("texture.png", :inprofile => "sRGB.icm", :out_profile => "AdobeRGB1998.icc").save("texture_out.png").free
@@ -1,9 +1,9 @@
1
- $direc = File.dirname(__FILE__)
2
-
3
- $LOAD_PATH.push("#{$direc}/../lib/")
4
-
5
- require 'rubygems'
6
- require 'devil/gosu'
7
-
8
- Devil.load("texture.png").save("texture_out1.jpg", :quality => 50).
9
- save("texture_out2.jpg").free
1
+ $direc = File.dirname(__FILE__)
2
+
3
+ $LOAD_PATH.push("#{$direc}/../lib/")
4
+
5
+ require 'rubygems'
6
+ require 'devil/gosu'
7
+
8
+ Devil.load("texture.png").save("texture_out1.jpg", :quality => 50).
9
+ save("texture_out2.jpg").free
@@ -1,30 +1,30 @@
1
- require 'rubygems'
2
- require 'devil'
3
-
4
- algorithms = {
5
- ILU::NEAREST => :nearest,
6
- ILU::LINEAR => :linear,
7
- ILU::BILINEAR => :bilinear,
8
- ILU::SCALE_BOX => :scale_box,
9
- ILU::SCALE_TRIANGLE => :scale_triangle,
10
- ILU::SCALE_BELL => :scale_bell,
11
- ILU::SCALE_BSPLINE => :scale_bspline,
12
- ILU::SCALE_LANCZOS3 => :scale_lanczos3,
13
- ILU::SCALE_MITCHELL => :scale_mitchell
14
- }
15
-
16
-
17
- algorithms.each do |key, value|
18
- puts "Generating image using filter: #{value}"
19
- IL.Init
20
-
21
- name = IL.GenImages(1)[0]
22
- IL.BindImage(name)
23
- IL.LoadImage("texture.jpg")
24
- ILU.ImageParameter(ILU::FILTER, key)
25
-
26
- ILU.Scale(100, 100, 1)
27
- IL.Enable(IL::FILE_OVERWRITE)
28
- IL.SaveImage("scaling_test_#{value}.jpg")
29
-
30
- end
1
+ require 'rubygems'
2
+ require 'devil'
3
+
4
+ algorithms = {
5
+ ILU::NEAREST => :nearest,
6
+ ILU::LINEAR => :linear,
7
+ ILU::BILINEAR => :bilinear,
8
+ ILU::SCALE_BOX => :scale_box,
9
+ ILU::SCALE_TRIANGLE => :scale_triangle,
10
+ ILU::SCALE_BELL => :scale_bell,
11
+ ILU::SCALE_BSPLINE => :scale_bspline,
12
+ ILU::SCALE_LANCZOS3 => :scale_lanczos3,
13
+ ILU::SCALE_MITCHELL => :scale_mitchell
14
+ }
15
+
16
+
17
+ algorithms.each do |key, value|
18
+ puts "Generating image using filter: #{value}"
19
+ IL.Init
20
+
21
+ name = IL.GenImages(1)[0]
22
+ IL.BindImage(name)
23
+ IL.LoadImage("texture.jpg")
24
+ ILU.ImageParameter(ILU::FILTER, key)
25
+
26
+ ILU.Scale(100, 100, 1)
27
+ IL.Enable(IL::FILE_OVERWRITE)
28
+ IL.SaveImage("scaling_test_#{value}.jpg")
29
+
30
+ end