texplay 0.2.800-i386-mingw32 → 0.2.900-i386-mingw32

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,75 +1,75 @@
1
- require 'rubygems'
2
- require 'common'
3
- require 'gosu'
4
- require 'texplay'
5
-
6
-
7
- class W < Gosu::Window
8
- def initialize
9
- super(1024, 768, false, 20)
10
- @img = Gosu::Image.new(self, "#{Common::MEDIA}/sunset.png")
11
- @img.rect 0,0, @img.width - 1, @img.height - 1
12
-
13
- # testing Gosu::Image#dup
14
- # adding an ivar
15
- @img.instance_variable_set(:@horse, :love)
16
-
17
- # adding a method on the singleton
18
- class << @img
19
- def little
20
- :little
21
- end
22
- end
23
-
24
- # clone the image.
25
- # NB #clone also copies singleton
26
- @bunk = @img.clone
27
-
28
- # should output :love
29
- puts @bunk.instance_variable_get(:@horse)
30
-
31
- # should output :little
32
- puts @bunk.little
33
-
34
- # add a red line to the copy to identify it
35
- #@bunk.line 0, 0, 1024, 1024, :color => :red
36
-
37
- @bunk.each(:region =>[200,200,350,350]) { |c,x,y|
38
-
39
- num_pixels = 0
40
- total = [0, 0, 0, 0]
41
- @bunk.circle x, y, 2,
42
- :color_control => proc { |v|
43
- if v
44
- total[0] += v[0]
45
- total[1] += v[1]
46
- total[2] += v[2]
47
- total[3] += v[3]
48
-
49
- num_pixels += 1
50
- end
51
- :none
52
- }
53
-
54
- c[0] = total[0] / num_pixels.to_f
55
- c[1] = total[1] / num_pixels.to_f
56
- c[2] = total[2] / num_pixels.to_f
57
- c[3] = total[3] / num_pixels.to_f
58
- }
59
-
60
- end
61
-
62
- def draw
63
- x = @img.width * rand
64
- y = @img.height * rand
65
-
66
- @img.draw 100, 50,1
67
- @bunk.draw 500, 300,1
68
- end
69
-
70
- end
71
-
72
-
73
- w = W.new
74
- w.show
75
-
1
+ require 'rubygems'
2
+ require 'common'
3
+ require 'gosu'
4
+ require 'texplay'
5
+
6
+
7
+ class W < Gosu::Window
8
+ def initialize
9
+ super(1024, 768, false, 20)
10
+ @img = Gosu::Image.new(self, "#{Common::MEDIA}/sunset.png")
11
+ @img.rect 0,0, @img.width - 1, @img.height - 1
12
+
13
+ # testing Gosu::Image#dup
14
+ # adding an ivar
15
+ @img.instance_variable_set(:@horse, :love)
16
+
17
+ # adding a method on the singleton
18
+ class << @img
19
+ def little
20
+ :little
21
+ end
22
+ end
23
+
24
+ # clone the image.
25
+ # NB #clone also copies singleton
26
+ @bunk = @img.clone
27
+
28
+ # should output :love
29
+ puts @bunk.instance_variable_get(:@horse)
30
+
31
+ # should output :little
32
+ puts @bunk.little
33
+
34
+ # add a red line to the copy to identify it
35
+ #@bunk.line 0, 0, 1024, 1024, :color => :red
36
+
37
+ @bunk.each(:region =>[200,200,350,350]) { |c,x,y|
38
+
39
+ num_pixels = 0
40
+ total = [0, 0, 0, 0]
41
+ @bunk.circle x, y, 2,
42
+ :color_control => proc { |v|
43
+ if v
44
+ total[0] += v[0]
45
+ total[1] += v[1]
46
+ total[2] += v[2]
47
+ total[3] += v[3]
48
+
49
+ num_pixels += 1
50
+ end
51
+ :none
52
+ }
53
+
54
+ c[0] = total[0] / num_pixels.to_f
55
+ c[1] = total[1] / num_pixels.to_f
56
+ c[2] = total[2] / num_pixels.to_f
57
+ c[3] = total[3] / num_pixels.to_f
58
+ }
59
+
60
+ end
61
+
62
+ def draw
63
+ x = @img.width * rand
64
+ y = @img.height * rand
65
+
66
+ @img.draw 100, 50,1
67
+ @bunk.draw 500, 300,1
68
+ end
69
+
70
+ end
71
+
72
+
73
+ w = W.new
74
+ w.show
75
+
@@ -1,42 +1,42 @@
1
- require 'rubygems'
2
- require 'common'
3
- require 'gosu'
4
- require 'texplay'
5
-
6
-
7
- class W < Gosu::Window
8
- def initialize
9
- super(1024, 768, false, 20)
10
- @img = Gosu::Image.new(self, "#{Common::MEDIA}/sunset.png")
11
-
12
- # each can accept a block of two types of arity:
13
- # arity 1 - yields just the pixel color
14
- # arity 3 - yield the pixel color, and the x and y
15
-
16
- # max out the blue component of every pixel
17
- @img.each { |v| v[2] = 1 }
18
-
19
- # a gradient from 0 red to 1 red
20
- @img.each(:region => [100, 100, 200, 200]) do |c, x, y|
21
- c[0] = (x - 100) / 100.0
22
- end
23
-
24
- # another gradient, this time blocking out everything except red (and alpha)
25
- @img.each(:region => [100, 250, 200, 350]) do |c, x, y|
26
- c[0] = (x - 100) / 100.0
27
- c[1] = 0
28
- c[2] = 0
29
- end
30
- end
31
-
32
- def draw
33
-
34
- @img.draw 100, 50,1
35
- end
36
-
37
- end
38
-
39
-
40
- w = W.new
41
- w.show
42
-
1
+ require 'rubygems'
2
+ require 'common'
3
+ require 'gosu'
4
+ require 'texplay'
5
+
6
+
7
+ class W < Gosu::Window
8
+ def initialize
9
+ super(1024, 768, false, 20)
10
+ @img = Gosu::Image.new(self, "#{Common::MEDIA}/sunset.png")
11
+
12
+ # each can accept a block of two types of arity:
13
+ # arity 1 - yields just the pixel color
14
+ # arity 3 - yield the pixel color, and the x and y
15
+
16
+ # max out the blue component of every pixel
17
+ @img.each { |v| v[2] = 1 }
18
+
19
+ # a gradient from 0 red to 1 red
20
+ @img.each(:region => [100, 100, 200, 200]) do |c, x, y|
21
+ c[0] = (x - 100) / 100.0
22
+ end
23
+
24
+ # another gradient, this time blocking out everything except red (and alpha)
25
+ @img.each(:region => [100, 250, 200, 350]) do |c, x, y|
26
+ c[0] = (x - 100) / 100.0
27
+ c[1] = 0
28
+ c[2] = 0
29
+ end
30
+ end
31
+
32
+ def draw
33
+
34
+ @img.draw 100, 50,1
35
+ end
36
+
37
+ end
38
+
39
+
40
+ w = W.new
41
+ w.show
42
+
@@ -1,35 +1,35 @@
1
- require 'rubygems'
2
- require 'common'
3
- require 'texplay'
4
-
5
-
6
- class W < Gosu::Window
7
- def initialize
8
- super(1024, 768, false, 20)
9
- @img = Gosu::Image.new(self, "#{Common::MEDIA}/empty2.png")
10
-
11
- # put a border on the image
12
- @img.rect 0,0, @img.width - 1, @img.height - 1
13
-
14
- @length = 0
15
- end
16
-
17
- def draw
18
-
19
- # quite a cool effect, very slow of course, because it's using turtle and fill
20
- @img.paint {
21
- forward(@length, true, :color => :red)
22
- turn(170)
23
- @length += 5
24
- fill (@img.width * rand), (@img.height * rand), :color => :random, :glow => true
25
- }
26
-
27
- @img.draw 100, 50,1
28
- end
29
-
30
- end
31
-
32
-
33
- w = W.new
34
- w.show
35
-
1
+ require 'rubygems'
2
+ require 'common'
3
+ require 'texplay'
4
+
5
+
6
+ class W < Gosu::Window
7
+ def initialize
8
+ super(1024, 768, false, 20)
9
+ @img = Gosu::Image.new(self, "#{Common::MEDIA}/empty2.png")
10
+
11
+ # put a border on the image
12
+ @img.rect 0,0, @img.width - 1, @img.height - 1
13
+
14
+ @length = 0
15
+ end
16
+
17
+ def draw
18
+
19
+ # quite a cool effect, very slow of course, because it's using turtle and fill
20
+ @img.paint {
21
+ forward(@length, true, :color => :red)
22
+ turn(170)
23
+ @length += 5
24
+ fill (@img.width * rand), (@img.height * rand), :color => :random, :glow => true
25
+ }
26
+
27
+ @img.draw 100, 50,1
28
+ end
29
+
30
+ end
31
+
32
+
33
+ w = W.new
34
+ w.show
35
+
@@ -1,44 +1,44 @@
1
- require 'rubygems'
2
- require 'common'
3
- require 'texplay'
4
-
5
-
6
- class W < Gosu::Window
7
- def initialize
8
- super(1024, 768, false, 20)
9
- @img = TexPlay::create_blank_image(self, 1022, 800)
10
- @tp = Gosu::Image.new(self, "#{Common::MEDIA}/texplay.png")
11
- @gosu = Gosu::Image.new(self, "#{Common::MEDIA}/sand1.png")
12
-
13
- points = []
14
-
15
- # NOTE: TexPlay also accepts points. a 'point' is any object that responds to 'x' or y
16
- # NOTE: current maximum points for a bezier is 13
17
- (0..@img.width + 90).step(185) { |x|
18
- p = TexPlay::TPPoint.new
19
- p.x = x
20
- p.y = @img.height * rand
21
-
22
- points << p
23
- }
24
-
25
- @img.bezier points
26
-
27
- # NOTE: the :texture hash argument works on ALL drawing actions; not just fills
28
- @img.fill 300, 650, :texture => @gosu
29
-
30
- # let's demonstrate by drawing a circle using the gosu.png texture
31
- # NOTE: :texture even works on lines, boxes, polylines, beziers etc.
32
- @img.circle 400, 50, 40, :fill => true, :texture => @tp
33
- end
34
-
35
- def draw
36
- @img.draw 10, 10,1
37
- end
38
-
39
- end
40
-
41
-
42
- w = W.new
43
- w.show
44
-
1
+ require 'rubygems'
2
+ require 'common'
3
+ require 'texplay'
4
+
5
+
6
+ class W < Gosu::Window
7
+ def initialize
8
+ super(1024, 768, false, 20)
9
+ @img = TexPlay::create_blank_image(self, 1022, 800)
10
+ @tp = Gosu::Image.new(self, "#{Common::MEDIA}/texplay.png")
11
+ @gosu = Gosu::Image.new(self, "#{Common::MEDIA}/sand1.png")
12
+
13
+ points = []
14
+
15
+ # NOTE: TexPlay also accepts points. a 'point' is any object that responds to 'x' or y
16
+ # NOTE: current maximum points for a bezier is 13
17
+ (0..@img.width + 90).step(185) { |x|
18
+ p = TexPlay::TPPoint.new
19
+ p.x = x
20
+ p.y = @img.height * rand
21
+
22
+ points << p
23
+ }
24
+
25
+ @img.bezier points
26
+
27
+ # NOTE: the :texture hash argument works on ALL drawing actions; not just fills
28
+ @img.fill 300, 650, :texture => @gosu
29
+
30
+ # let's demonstrate by drawing a circle using the gosu.png texture
31
+ # NOTE: :texture even works on lines, boxes, polylines, beziers etc.
32
+ @img.circle 400, 50, 40, :fill => true, :texture => @tp
33
+ end
34
+
35
+ def draw
36
+ @img.draw 10, 10,1
37
+ end
38
+
39
+ end
40
+
41
+
42
+ w = W.new
43
+ w.show
44
+
@@ -1,49 +1,49 @@
1
- require 'rubygems'
2
- require 'common'
3
- require 'texplay'
4
-
5
- class W < Gosu::Window
6
- def initialize
7
- super(1024, 768, false, 20)
8
- @img = Gosu::Image.new(self, "#{Common::MEDIA}/empty2.png")
9
- @tp = Gosu::Image.new(self, "#{Common::MEDIA}/texplay.png")
10
- @gosu = Gosu::Image.new(self, "#{Common::MEDIA}/gosu.png")
11
-
12
- # put a border on the image
13
- @img.rect 0,0, @img.width - 1, @img.height - 1
14
-
15
- points = []
16
-
17
- # NOTE: TexPlay also accepts points. a 'point' is any object that responds to 'x' or 'y'
18
- # NOTE: current maximum points for a bezier is 13
19
- (0..@img.width).step(50) { |x|
20
- p = TexPlay::TPPoint.new
21
- p.x = x
22
- p.y = @img.height * rand
23
-
24
- points << p
25
- }
26
-
27
- @img.bezier points, :color => :white
28
-
29
-
30
- # NOTE: the :texture hash argument works on ALL drawing actions; not just fills
31
- @img.fill 300, 480, :texture => @tp
32
-
33
- # let's demonstrate by drawing a circle using the gosu.png texture
34
- # NOTE: :texture even works on lines, boxes, polylines, beziers etc.
35
- @img.circle 400, 50, 40, :fill => true, :texture => @gosu
36
-
37
- end
38
-
39
- def draw
40
-
41
- @img.draw 100, 50,1
42
- end
43
-
44
- end
45
-
46
-
47
- w = W.new
48
- w.show
49
-
1
+ require 'rubygems'
2
+ require 'common'
3
+ require 'texplay'
4
+
5
+ class W < Gosu::Window
6
+ def initialize
7
+ super(1024, 768, false, 20)
8
+ @img = Gosu::Image.new(self, "#{Common::MEDIA}/empty2.png")
9
+ @tp = Gosu::Image.new(self, "#{Common::MEDIA}/texplay.png")
10
+ @gosu = Gosu::Image.new(self, "#{Common::MEDIA}/gosu.png")
11
+
12
+ # put a border on the image
13
+ @img.rect 0,0, @img.width - 1, @img.height - 1
14
+
15
+ points = []
16
+
17
+ # NOTE: TexPlay also accepts points. a 'point' is any object that responds to 'x' or 'y'
18
+ # NOTE: current maximum points for a bezier is 13
19
+ (0..@img.width).step(50) { |x|
20
+ p = TexPlay::TPPoint.new
21
+ p.x = x
22
+ p.y = @img.height * rand
23
+
24
+ points << p
25
+ }
26
+
27
+ @img.bezier points, :color => :white
28
+
29
+
30
+ # NOTE: the :texture hash argument works on ALL drawing actions; not just fills
31
+ @img.fill 300, 480, :texture => @tp
32
+
33
+ # let's demonstrate by drawing a circle using the gosu.png texture
34
+ # NOTE: :texture even works on lines, boxes, polylines, beziers etc.
35
+ @img.circle 400, 50, 40, :fill => true, :texture => @gosu
36
+
37
+ end
38
+
39
+ def draw
40
+
41
+ @img.draw 100, 50,1
42
+ end
43
+
44
+ end
45
+
46
+
47
+ w = W.new
48
+ w.show
49
+