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.
data/examples/common.rb CHANGED
@@ -1,8 +1,8 @@
1
- $LOAD_PATH.push(File.dirname(__FILE__) + '/../lib/')
2
-
3
- require 'rubygems'
4
- require 'texplay'
5
-
6
- module Common
7
- MEDIA = File.dirname(__FILE__) + '/media'
8
- end
1
+ $LOAD_PATH.push(File.dirname(__FILE__) + '/../lib/')
2
+
3
+ require 'rubygems'
4
+ require 'texplay'
5
+
6
+ module Common
7
+ MEDIA = File.dirname(__FILE__) + '/media'
8
+ end
@@ -1,31 +1,31 @@
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
- # put a border on the image
13
- @img.rect 0,0, @img.width - 1, @img.height - 1
14
-
15
- @img.rect 1, 1, @img.width - 2, @img.height - 2, :fill => true, :texture => @tp
16
-
17
- # NOTE: the current implementation of alpha blending is a bit tempermental, i need to think it
18
- # through a bit more...
19
- @img.rect 100, 100, 300, 300, :color => [1, 1, 1, 0.8], :alpha_blend => true, :fill => true
20
- end
21
-
22
- def draw
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 '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
+ # put a border on the image
13
+ @img.rect 0,0, @img.width - 1, @img.height - 1
14
+
15
+ @img.rect 1, 1, @img.width - 2, @img.height - 2, :fill => true, :texture => @tp
16
+
17
+ # NOTE: the current implementation of alpha blending is a bit tempermental, i need to think it
18
+ # through a bit more...
19
+ @img.rect 100, 100, 300, 300, :color => [1, 1, 1, 0.8], :alpha_blend => true, :fill => true
20
+ end
21
+
22
+ def draw
23
+ @img.draw 100, 50,1
24
+ end
25
+
26
+ end
27
+
28
+
29
+ w = W.new
30
+ w.show
31
+
@@ -1,42 +1,42 @@
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, 500, 500)
10
-
11
- # put a border on the image
12
- @img.rect 0,0, @img.width - 1, @img.height - 1
13
-
14
- points = []
15
-
16
- # NOTE: TexPlay also accepts points. a 'point' is any object that responds to 'x' or 'y'
17
- # NOTE: current maximum points for a bezier is 13
18
- (0..@img.width + 100).step(40) { |x|
19
- p = TexPlay::TPPoint.new
20
- p.x = x
21
- p.y = @img.height * rand
22
-
23
- points << p
24
- }
25
-
26
- # making the bezier
27
- @img.bezier points, :color => :red
28
-
29
- # NOTE: can 'close' a bezier curve too (as with polylines)
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 'texplay'
4
+
5
+
6
+ class W < Gosu::Window
7
+ def initialize
8
+ super(1024, 768, false, 20)
9
+ @img = TexPlay::create_blank_image(self, 500, 500)
10
+
11
+ # put a border on the image
12
+ @img.rect 0,0, @img.width - 1, @img.height - 1
13
+
14
+ points = []
15
+
16
+ # NOTE: TexPlay also accepts points. a 'point' is any object that responds to 'x' or 'y'
17
+ # NOTE: current maximum points for a bezier is 13
18
+ (0..@img.width + 100).step(40) { |x|
19
+ p = TexPlay::TPPoint.new
20
+ p.x = x
21
+ p.y = @img.height * rand
22
+
23
+ points << p
24
+ }
25
+
26
+ # making the bezier
27
+ @img.bezier points, :color => :red
28
+
29
+ # NOTE: can 'close' a bezier curve too (as with polylines)
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,69 +1,69 @@
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
- # When using color_control the pixel the draw action is currently manipulating is yielded
16
- # to the proc. This gives you pixel-level control over the drawing.
17
- # (NOTE: the return value of the proc is used as the pixel color, so it should be a 4 element array or
18
- # a valid color symbol)
19
-
20
- # color_control accepts procs of 4 types:
21
- # arity of 0: nothing is yielded and color is set by return value of block
22
- # arity of 1: just the destination pixel color is yielded
23
- # arity of 2: both the destination and the source pixel colors are yielded (in that order)
24
- # arity of 3: the destination pixel color is yielded along with the x and y coords of the current pixel
25
- # arity of 4: both the destination and the source pixel colours are yielded as well as the x and y vals
26
-
27
- # just drawing an area to fill
28
- @img.polyline [30, 30, 100, 100, 200, 76, 300, 9, 50, 200], :color => :random, :closed => true
29
-
30
- # below we are 'faking' a texture fill using color_control
31
- @img.fill 42, 70, :color_control => proc { |c, x, y|
32
- @tp.get_pixel(x % @tp.width, y % @tp.height)
33
- }
34
-
35
- # merging two images together
36
- @img.rect 100, 200, 400, 300, :fill => true, :texture => @gosu,
37
- :color_control => proc { |c1, c2, x, y|
38
- c1 = @tp.get_pixel(x % @tp.width, y % @tp.height)
39
- c1[0] = (c1[0] + c2[0]) / 2
40
- c1[1] = (c1[1] + c2[1]) / 2
41
- c1[2] = (c1[2] + c2[2]) / 2
42
- c1[3] = 1
43
- c1
44
- }
45
-
46
- # we can even use color_control just for the use of the (x, y) values.
47
- # here we simply use the x, y values to make our own circle with a rough edge
48
- @img.circle 200,400, 70,
49
- :color_control => proc { |c,x,y|
50
- @img.pixel(x + (rand(4) - 2), y + (rand(4) - 2))
51
- :none # this ensures that the 'actual' circle isn't drawn, instead its coordinates are
52
- # simply utilized to draw a ragged edge of another circle (using @img.pixel)
53
- }
54
-
55
- # this just fills a rect with random colours
56
- @img.rect 400, 400, 470, 470, :fill => true, :color_control => proc { :rand }
57
- end
58
-
59
- def draw
60
-
61
- @img.draw 100, 50,1
62
- end
63
-
64
- end
65
-
66
-
67
- w = W.new
68
- w.show
69
-
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
+ # When using color_control the pixel the draw action is currently manipulating is yielded
16
+ # to the proc. This gives you pixel-level control over the drawing.
17
+ # (NOTE: the return value of the proc is used as the pixel color, so it should be a 4 element array or
18
+ # a valid color symbol)
19
+
20
+ # color_control accepts procs of 4 types:
21
+ # arity of 0: nothing is yielded and color is set by return value of block
22
+ # arity of 1: just the destination pixel color is yielded
23
+ # arity of 2: both the destination and the source pixel colors are yielded (in that order)
24
+ # arity of 3: the destination pixel color is yielded along with the x and y coords of the current pixel
25
+ # arity of 4: both the destination and the source pixel colours are yielded as well as the x and y vals
26
+
27
+ # just drawing an area to fill
28
+ @img.polyline [30, 30, 100, 100, 200, 76, 300, 9, 50, 200], :color => :random, :closed => true
29
+
30
+ # below we are 'faking' a texture fill using color_control
31
+ @img.fill 42, 70, :color_control => proc { |c, x, y|
32
+ @tp.get_pixel(x % @tp.width, y % @tp.height)
33
+ }
34
+
35
+ # merging two images together
36
+ @img.rect 100, 200, 400, 300, :fill => true, :texture => @gosu,
37
+ :color_control => proc { |c1, c2, x, y|
38
+ c1 = @tp.get_pixel(x % @tp.width, y % @tp.height)
39
+ c1[0] = (c1[0] + c2[0]) / 2
40
+ c1[1] = (c1[1] + c2[1]) / 2
41
+ c1[2] = (c1[2] + c2[2]) / 2
42
+ c1[3] = 1
43
+ c1
44
+ }
45
+
46
+ # we can even use color_control just for the use of the (x, y) values.
47
+ # here we simply use the x, y values to make our own circle with a rough edge
48
+ @img.circle 200,400, 70,
49
+ :color_control => proc { |c,x,y|
50
+ @img.pixel(x + (rand(4) - 2), y + (rand(4) - 2))
51
+ :none # this ensures that the 'actual' circle isn't drawn, instead its coordinates are
52
+ # simply utilized to draw a ragged edge of another circle (using @img.pixel)
53
+ }
54
+
55
+ # this just fills a rect with random colours
56
+ @img.rect 400, 400, 470, 470, :fill => true, :color_control => proc { :rand }
57
+ end
58
+
59
+ def draw
60
+
61
+ @img.draw 100, 50,1
62
+ end
63
+
64
+ end
65
+
66
+
67
+ w = W.new
68
+ w.show
69
+
@@ -1,67 +1,64 @@
1
- require 'rubygems'
2
- require 'common'
3
- require 'gosu'
4
- require 'texplay'
5
- #require 'devil/gosu'
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
- @x = 100
12
- @y = 100
13
-
14
- @x2 = 400
15
- @y2 = 100
16
- @rad = 50
17
- @s = true
18
-
19
- @copy = TexPlay.create_blank_image(self, @rad * 2 + 1, @rad * 2 + 1)
20
- @copy2 = TexPlay.create_blank_image(self, @rad * 2 + 1, @rad * 2 + 1)
21
- end
22
-
23
- def draw
24
-
25
-
26
- @x += 1
27
- @y += 1
28
-
29
- @x2 -= 1
30
- @y2 += 1
31
-
32
-
33
- @copy2.splice @img, 0, 0, :crop => [@x2 - @rad, @y2 - @rad, @x2 + @rad, @y2 + @rad], :sync_mode => :no_sync
34
- @copy.splice @img, 0, 0, :crop => [@x - @rad, @y - @rad, @x + @rad, @y + @rad], :sync_mode => :no_sync
35
- @img.
36
- circle @x, @y, @rad, :fill => true, :lerp => 0.3, :color => :red
37
-
38
- @img.circle @x2, @y2, @rad, :fill => true, :lerp => 0.3, :color => :blue
39
- # :color_control => { :mult => [0.3, 0.9, 0.3, 1] }
40
-
41
-
42
- # @img.force_sync [0,0, @img.width, @img.height]
43
-
44
- @img.draw 10, 10,1
45
-
46
- if button_down?(Gosu::KbEscape)
47
- IL.Enable(IL::ORIGIN_SET)
48
- IL.OriginFunc(IL::ORIGIN_UPPER_LEFT)
49
- # screenshot.crop(0,0, 500, 500).save("screenshot.jpg").free
50
- exit
51
- end
52
-
53
- end
54
-
55
- def update
56
- @img.splice @copy, @x - @rad, @y - @rad if !@s
57
- @img.splice @copy2, @x2 - @rad, @y2 - @rad if !@s
58
- @s = nil if @s
59
-
60
- end
61
-
62
- end
63
-
64
-
65
- w = W.new
66
- w.show
67
-
1
+ require 'rubygems'
2
+ require 'common'
3
+ require 'gosu'
4
+ require 'texplay'
5
+ #require 'devil/gosu'
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
+ @x = 100
12
+ @y = 100
13
+
14
+ @x2 = 400
15
+ @y2 = 100
16
+ @rad = 70
17
+ @s = true
18
+
19
+ @copy = TexPlay.create_image(self, @rad * 2 + 1, @rad * 2 + 1)
20
+ @copy2 = TexPlay.create_image(self, @rad * 2 + 1, @rad * 2 + 1)
21
+ end
22
+
23
+ def draw
24
+
25
+
26
+ @x += 3
27
+ @y += 3
28
+
29
+ @x2 -= 3
30
+ @y2 += 3
31
+
32
+
33
+ @copy2.splice @img, 0, 0, :crop => [@x2 - @rad, @y2 - @rad, @x2 + @rad, @y2 + @rad], :sync_mode => :no_sync
34
+ @copy.splice @img, 0, 0, :crop => [@x - @rad, @y - @rad, @x + @rad, @y + @rad], :sync_mode => :no_sync
35
+ @img.rect @x - @rad, @y - @rad, @x + @rad, @y + @rad, :fill => true, :mode => :overlay, :color => :red
36
+
37
+ @img.rect @x2 - @rad, @y2 - @rad, @x2 + @rad, @y2 + @rad, :fill => true, :mode => :overlay, :color => :blue
38
+
39
+ # @img.force_sync [0,0, @img.width, @img.height]
40
+
41
+ @img.draw 10, 10,1
42
+
43
+ if button_down?(Gosu::KbEscape)
44
+ IL.Enable(IL::ORIGIN_SET)
45
+ IL.OriginFunc(IL::ORIGIN_UPPER_LEFT)
46
+ # screenshot.crop(0,0, 500, 500).save("screenshot.jpg").free
47
+ exit
48
+ end
49
+
50
+ end
51
+
52
+ def update
53
+ @img.splice @copy, @x - @rad, @y - @rad if !@s
54
+ @img.splice @copy2, @x2 - @rad, @y2 - @rad if !@s
55
+ @s = nil if @s
56
+
57
+ end
58
+
59
+ end
60
+
61
+
62
+ w = W.new
63
+ w.show
64
+
@@ -0,0 +1,65 @@
1
+ require 'rubygems'
2
+ require 'common'
3
+ require 'gosu'
4
+ require 'texplay'
5
+ #require 'devil/gosu'
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
+ @x = 100
12
+ @y = 100
13
+
14
+ @x2 = 400
15
+ @y2 = 100
16
+ @rad = 70
17
+ @s = true
18
+
19
+ @copy = TexPlay.create_image(self, @rad * 2 + 1, @rad * 2 + 1)
20
+ @copy2 = TexPlay.create_image(self, @rad * 2 + 1, @rad * 2 + 1)
21
+ end
22
+
23
+ def draw
24
+
25
+
26
+ @x += 3
27
+ @y += 3
28
+
29
+ @x2 -= 3
30
+ @y2 += 3
31
+
32
+
33
+ @copy2.splice @img, 0, 0, :crop => [@x2 - @rad, @y2 - @rad, @x2 + @rad, @y2 + @rad], :sync_mode => :no_sync
34
+ @copy.splice @img, 0, 0, :crop => [@x - @rad, @y - @rad, @x + @rad, @y + @rad], :sync_mode => :no_sync
35
+
36
+ @img.circle @x, @y, @rad, :fill => true, :mode => :overlay, :color => :red
37
+
38
+ @img.rect @x2 - @rad, @y2 - @rad, @x2 + @rad, @y2 + @rad, :fill => true, :mode => :overlay, :color => :blue
39
+
40
+ # @img.force_sync [0,0, @img.width, @img.height]
41
+
42
+ @img.draw 10, 10,1
43
+
44
+ if button_down?(Gosu::KbEscape)
45
+ IL.Enable(IL::ORIGIN_SET)
46
+ IL.OriginFunc(IL::ORIGIN_UPPER_LEFT)
47
+ # screenshot.crop(0,0, 500, 500).save("screenshot.jpg").free
48
+ exit
49
+ end
50
+
51
+ end
52
+
53
+ def update
54
+ @img.splice @copy, @x - @rad, @y - @rad if !@s
55
+ @img.splice @copy2, @x2 - @rad, @y2 - @rad if !@s
56
+ @s = nil if @s
57
+
58
+ end
59
+
60
+ end
61
+
62
+
63
+ w = W.new
64
+ w.show
65
+