texplay 0.2.800-i386-mswin32 → 0.2.900-i386-mswin32

Sign up to get free protection for your applications and to get access to all the features.
@@ -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
+
@@ -1,31 +1,31 @@
1
- require 'rubygems'
2
- require 'common'
3
- require 'gosu'
4
- require 'texplay'
5
-
6
- class W < Gosu::Window
7
- def initialize
8
- super(1024, 768, false, 20)
9
- @img = Gosu::Image.new(self, "#{Common::MEDIA}/sunset.png")
10
- @img.rect 0,0, @img.width - 1, @img.height - 1
11
-
12
- # test the fluent interface
13
- @img.
14
- line(0, 0, 1024, 1024).
15
- circle(20, 20, 50).
16
- rect 30, 30, 100, 100
17
- end
18
-
19
- def draw
20
- x = @img.width * rand
21
- y = @img.height * rand
22
-
23
- @img.draw 100, 50,1
24
- end
25
-
26
- end
27
-
28
-
29
- w = W.new
30
- w.show
31
-
1
+ require 'rubygems'
2
+ require 'common'
3
+ require 'gosu'
4
+ require 'texplay'
5
+
6
+ class W < Gosu::Window
7
+ def initialize
8
+ super(1024, 768, false, 20)
9
+ @img = Gosu::Image.new(self, "#{Common::MEDIA}/sunset.png")
10
+ @img.rect 0,0, @img.width - 1, @img.height - 1
11
+
12
+ # test the fluent interface
13
+ @img.
14
+ line(0, 0, 1024, 1024).
15
+ circle(20, 20, 50).
16
+ rect 30, 30, 100, 100
17
+ end
18
+
19
+ def draw
20
+ x = @img.width * rand
21
+ y = @img.height * rand
22
+
23
+ @img.draw 100, 50,1
24
+ end
25
+
26
+ end
27
+
28
+
29
+ w = W.new
30
+ w.show
31
+
@@ -1,34 +1,34 @@
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
- @width = @img.width
12
- @height = @img.height
13
-
14
- # turn alpha blending and filling on
15
- @img.set_options :alpha_blend => true, :fill => true
16
- end
17
-
18
- def draw
19
-
20
- # Gen_eval lets us use local instance vars within the block
21
- # even though the block appears to be getting instance_eval'd
22
- # for more information see gen_eval.c and object2module.c
23
- @img.paint {
24
- rect @width * rand, @height * rand, @width * rand, @height * rand,
25
- :color => [rand, rand ,rand, rand]
26
- }
27
-
28
- @img.draw 100, 50,1
29
- end
30
- end
31
-
32
- w = W.new
33
- w.show
34
-
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
+ @width = @img.width
12
+ @height = @img.height
13
+
14
+ # turn alpha blending and filling on
15
+ @img.set_options :alpha_blend => true, :fill => true
16
+ end
17
+
18
+ def draw
19
+
20
+ # Gen_eval lets us use local instance vars within the block
21
+ # even though the block appears to be getting instance_eval'd
22
+ # for more information see gen_eval.c and object2module.c
23
+ @img.paint {
24
+ rect @width * rand, @height * rand, @width * rand, @height * rand,
25
+ :color => [rand, rand ,rand, rand]
26
+ }
27
+
28
+ @img.draw 100, 50,1
29
+ end
30
+ end
31
+
32
+ w = W.new
33
+ w.show
34
+
@@ -1,47 +1,47 @@
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
- @tp = Gosu::Image.new(self, "#{Common::MEDIA}/texplay.png")
11
-
12
-
13
- # put a border on the image
14
- @img.rect 0,0, @img.width - 1, @img.height - 1
15
-
16
- # it can be annoying having to specify a bunch of :hash_arguments for every action
17
- # here is how you specify common hash args that all actions will use (in the same image)
18
-
19
- # all actions that respond to 'thickness' use a thickness of 8 pixels
20
- # also set the color to random
21
- @img.set_options :thickness => 8, :color => :rand
22
-
23
- @img.rect 100, 100, 200, 200, :fill => false
24
-
25
- # NOTE: for ngon, the parameters are as follows: x, y, radius, num_sides
26
- @img.ngon 400, 400, 40, 3
27
-
28
- # NOTE: the defaults can also be overidden:
29
- @img.ngon 400, 200, 90, 6, :thickness => 1
30
-
31
- # you can also delete the defaults
32
- @img.delete_options
33
-
34
- # this action will no longer have any default values
35
- @img.ngon 200, 400, 90, 10
36
- end
37
-
38
- def draw
39
- @img.draw 100, 50,1
40
- end
41
-
42
- end
43
-
44
-
45
- w = W.new
46
- w.show
47
-
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
+ @tp = Gosu::Image.new(self, "#{Common::MEDIA}/texplay.png")
11
+
12
+
13
+ # put a border on the image
14
+ @img.rect 0,0, @img.width - 1, @img.height - 1
15
+
16
+ # it can be annoying having to specify a bunch of :hash_arguments for every action
17
+ # here is how you specify common hash args that all actions will use (in the same image)
18
+
19
+ # all actions that respond to 'thickness' use a thickness of 8 pixels
20
+ # also set the color to random
21
+ @img.set_options :thickness => 8, :color => :rand
22
+
23
+ @img.rect 100, 100, 200, 200, :fill => false
24
+
25
+ # NOTE: for ngon, the parameters are as follows: x, y, radius, num_sides
26
+ @img.ngon 400, 400, 40, 3
27
+
28
+ # NOTE: the defaults can also be overidden:
29
+ @img.ngon 400, 200, 90, 6, :thickness => 1
30
+
31
+ # you can also delete the defaults
32
+ @img.delete_options
33
+
34
+ # this action will no longer have any default values
35
+ @img.ngon 200, 400, 90, 10
36
+ end
37
+
38
+ def draw
39
+ @img.draw 100, 50,1
40
+ end
41
+
42
+ end
43
+
44
+
45
+ w = W.new
46
+ w.show
47
+
@@ -0,0 +1,77 @@
1
+ require 'rubygems'
2
+ require 'common'
3
+ require 'gosu'
4
+ require 'texplay'
5
+
6
+ class W < Gosu::Window
7
+ def initialize
8
+ super(500, 500, false, 20)
9
+
10
+ @x1 = 10
11
+ @x2 = 200
12
+ @y1 = 10
13
+ @y2 = 10
14
+
15
+ @radius = 100.0
16
+ @inner = 20.0
17
+ @max_opacity = 0.5
18
+ @max_opacity2 = 0.5
19
+
20
+ penumbra = (@radius - @inner).to_i
21
+
22
+ @img = Gosu::Image.new(self, "#{Common::MEDIA}/maria.png")
23
+ #@img.rect(0, 0, @img.width - 1, @img.height - 1, :fill => true)
24
+
25
+ @circ2 = TexPlay.create_image(self, @radius * 2, @radius * 2)
26
+
27
+ @circ1 = TexPlay.create_image(self, @radius * 2, @radius * 2)
28
+
29
+
30
+ shading_step = @max_opacity2.to_f / penumbra.to_f
31
+ @radius.to_i.downto(@inner) { |r|
32
+ @circ1.circle @radius, @radius, r, :color => [1, 0, 0, ((@radius - r) * shading_step)],
33
+ :fill => true
34
+ }
35
+
36
+ @circ1.circle @radius, @radius, @inner, :color => [1, 0, 0, @max_opacity2], :fill => true
37
+
38
+ shading_step = @max_opacity.to_f / penumbra.to_f
39
+ @radius.to_i.downto(@inner) { |r|
40
+ @circ2.circle @radius, @radius, r, :color => [0, 0, 1, ((@radius - r) * shading_step)],
41
+ :fill => true
42
+ }
43
+
44
+ @circ2.circle @radius, @radius, @inner, :color => [0, 0, 1, @max_opacity], :fill => true
45
+ end
46
+
47
+ def draw
48
+ @x1 += 1
49
+ @y1 += 1
50
+
51
+ @x2 -= 1
52
+ @y2 += 1
53
+
54
+
55
+
56
+ @img.draw 10, 10,1
57
+ @circ1.draw @x1, @y1,1
58
+ @circ2.draw @x2, @y1,1
59
+
60
+ if button_down?(Gosu::KbEscape)
61
+ IL.Enable(IL::ORIGIN_SET)
62
+ IL.OriginFunc(IL::ORIGIN_UPPER_LEFT)
63
+ # screenshot.crop(0,0, 500, 500).save("screenshot.jpg").free
64
+ exit
65
+ end
66
+
67
+ end
68
+
69
+ def update
70
+ end
71
+
72
+ end
73
+
74
+
75
+ w = W.new
76
+ w.show
77
+
@@ -1,61 +1,61 @@
1
- require 'common'
2
- require 'gosu'
3
-
4
- Dragon = TexPlay::LSystem.new do
5
- rule "F" => "F"
6
- rule "X" => "X+YF+"
7
- rule "Y" => "-FX-Y"
8
- angle 90
9
-
10
- atom "FX"
11
- end
12
-
13
- Koch = TexPlay::LSystem.new do
14
- rule "F" => "F-F++F-F"
15
-
16
- angle 60
17
-
18
- atom "F"
19
- end
20
-
21
- Bush1 = TexPlay::LSystem.new do
22
- rule "F" => "F[-F]F[+F][F]"
23
-
24
- angle 20
25
- atom "F"
26
- end
27
-
28
- Bush2 = TexPlay::LSystem.new do
29
- rule "F" => "FF"
30
- rule "X" => "F[+X]F[-X]+X"
31
-
32
- angle 20
33
- atom "X"
34
- end
35
-
36
- Bush3 = TexPlay::LSystem.new do
37
- rule "F" => "FF"
38
- rule "X" => "F-[[X]+X]+F[+FX]-X"
39
-
40
- angle 22.5
41
- atom "X"
42
- end
43
-
44
-
45
-
46
- class W < Gosu::Window
47
- def initialize
48
- super(1024, 768, false, 20)
49
- @img = TexPlay::create_blank_image(self, 500, 500)
50
- @img.set_options :color => :rand
51
- @img.lsystem(400, 150, Koch, :order => 8, :line_length => 6)
52
- #@img.save("dragon.jpg")
53
- end
54
-
55
- def draw
56
- @img.draw(100,0,1)
57
- end
58
- end
59
-
60
- w = W.new
61
- w.show
1
+ require 'common'
2
+ require 'gosu'
3
+
4
+ Dragon = TexPlay::LSystem.new do
5
+ rule "F" => "F"
6
+ rule "X" => "X+YF+"
7
+ rule "Y" => "-FX-Y"
8
+ angle 90
9
+
10
+ atom "FX"
11
+ end
12
+
13
+ Koch = TexPlay::LSystem.new do
14
+ rule "F" => "F-F++F-F"
15
+
16
+ angle 60
17
+
18
+ atom "F"
19
+ end
20
+
21
+ Bush1 = TexPlay::LSystem.new do
22
+ rule "F" => "F[-F]F[+F][F]"
23
+
24
+ angle 20
25
+ atom "F"
26
+ end
27
+
28
+ Bush2 = TexPlay::LSystem.new do
29
+ rule "F" => "FF"
30
+ rule "X" => "F[+X]F[-X]+X"
31
+
32
+ angle 20
33
+ atom "X"
34
+ end
35
+
36
+ Bush3 = TexPlay::LSystem.new do
37
+ rule "F" => "FF"
38
+ rule "X" => "F-[[X]+X]+F[+FX]-X"
39
+
40
+ angle 22.5
41
+ atom "X"
42
+ end
43
+
44
+
45
+
46
+ class W < Gosu::Window
47
+ def initialize
48
+ super(1024, 768, false, 20)
49
+ @img = TexPlay::create_blank_image(self, 500, 500)
50
+ @img.set_options :color => :rand
51
+ @img.lsystem(400, 150, Koch, :order => 8, :line_length => 6)
52
+ #@img.save("dragon.jpg")
53
+ end
54
+
55
+ def draw
56
+ @img.draw(100,0,1)
57
+ end
58
+ end
59
+
60
+ w = W.new
61
+ w.show
@@ -1,27 +1,27 @@
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
- end
12
-
13
- def draw
14
- x = (@img.width - 100/2) * rand
15
- y = (@img.height - 100/2) * rand
16
-
17
- @img.splice @img, x, y + 1, :crop => [x, y, x + 100, y + 100]
18
-
19
- @img.draw 100, 50,1
20
- end
21
-
22
- end
23
-
24
-
25
- w = W.new
26
- w.show
27
-
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
+ end
12
+
13
+ def draw
14
+ x = (@img.width - 100/2) * rand
15
+ y = (@img.height - 100/2) * rand
16
+
17
+ @img.splice @img, x, y + 1, :crop => [x, y, x + 100, y + 100]
18
+
19
+ @img.draw 100, 50,1
20
+ end
21
+
22
+ end
23
+
24
+
25
+ w = W.new
26
+ w.show
27
+