texplay 0.2.720-i386-mswin32 → 0.2.721-i386-mswin32

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -28,8 +28,7 @@ specification = Gem::Specification.new do |s|
28
28
  s.extensions = ["ext/texplay/extconf.rb"]
29
29
  s.files = ["Rakefile", "README.markdown", "CHANGELOG",
30
30
  "lib/texplay.rb", "lib/texplay-contrib.rb", "lib/texplay/version.rb"] +
31
- FileList["ext/**/extconf.rb", "ext/**/*.h", "ext/**/*.c", "examples/*.rb",
32
- "examples/media/*"].to_a
31
+ FileList["ext/**/extconf.rb", "ext/**/*.h", "ext/**/*.c", "examples/*.rb", "examples/media/*"].to_a
33
32
  end
34
33
 
35
34
  Rake::ExtensionTask.new('texplay', specification) do |ext|
@@ -57,9 +56,8 @@ end
57
56
 
58
57
  s.files = ["Rakefile", "README.markdown", "CHANGELOG",
59
58
  "lib/texplay.rb", "lib/texplay-contrib.rb", "lib/texplay/version.rb", "lib/1.8/texplay.so",
60
- "lib/1.9/texplay.so"]
61
- FileList["examples/*.rb",
62
- "examples/media/*"].to_a
59
+ "lib/1.9/texplay.so"] +
60
+ FileList["examples/*.rb", "examples/media/*"].to_a
63
61
  end
64
62
 
65
63
  Rake::GemPackageTask.new(specification) do |package|
@@ -0,0 +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
@@ -0,0 +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
+
@@ -0,0 +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
+
@@ -0,0 +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
+
@@ -0,0 +1,68 @@
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]
34
+ @copy.splice @img, 0, 0, :crop => [@x - @rad, @y - @rad, @x + @rad, @y + @rad]
35
+ @img.
36
+ circle @x, @y, @rad, :fill => true,
37
+ :color_control => { :mult => [1.0, 0.5, 0.5, 1] }
38
+
39
+ # circle @x2, @y2, @rad, :fill => true,
40
+ # :color_control => { :mult => [0.3, 0.9, 0.3, 1] }
41
+
42
+
43
+ # @img.force_sync [0,0, @img.width, @img.height]
44
+
45
+ @img.draw 10, 10,1
46
+
47
+ if button_down?(Gosu::KbEscape)
48
+ IL.Enable(IL::ORIGIN_SET)
49
+ IL.OriginFunc(IL::ORIGIN_UPPER_LEFT)
50
+ # screenshot.crop(0,0, 500, 500).save("screenshot.jpg").free
51
+ exit
52
+ end
53
+
54
+ end
55
+
56
+ def update
57
+ @img.splice @copy, @x - @rad, @y - @rad if !@s
58
+ @img.splice @copy2, @x2 - @rad, @y2 - @rad if !@s
59
+ @s = nil if @s
60
+
61
+ end
62
+
63
+ end
64
+
65
+
66
+ w = W.new
67
+ w.show
68
+
@@ -0,0 +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
+
@@ -0,0 +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
+
@@ -0,0 +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
+
@@ -0,0 +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
+
@@ -0,0 +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
+
@@ -0,0 +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
+
@@ -0,0 +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
+
@@ -0,0 +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
+
@@ -0,0 +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
@@ -0,0 +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
+
@@ -0,0 +1,43 @@
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
+ points = []
15
+
16
+ # NOTE: TexPlay also accepts points. a 'point' is any object that responds to 'x' or 'y'
17
+ 10.times {
18
+ p = TexPlay::TPPoint.new
19
+ p.x = @img.width * rand
20
+ p.y = @img.height * rand
21
+
22
+ points << p
23
+ }
24
+
25
+
26
+ # what if we want to turn a polyline into a polygon?
27
+ @img.polyline points, :closed => true, :color => :blue
28
+ @img.polyline points, :color => :red
29
+ end
30
+
31
+ def draw
32
+
33
+ # NOTE: (when viewing) the blue line is the extra line added to close the polygon,
34
+ # red lines are original polyline
35
+ @img.draw 100, 50,1
36
+ end
37
+
38
+ end
39
+
40
+
41
+ w = W.new
42
+ w.show
43
+
@@ -0,0 +1,29 @@
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}/logo.png")
11
+ @img2 = TexPlay::create_blank_image(self, 500, 500)
12
+
13
+ @img2.splice_and_scale @img, 0, 50, :factor => 2
14
+ @img2.splice @img, 0, 200
15
+ end
16
+
17
+ def draw
18
+ x = @img.width * rand
19
+ y = @img.height * rand
20
+
21
+ @img2.draw 100, 100,1
22
+ end
23
+
24
+ end
25
+
26
+
27
+ w = W.new
28
+ w.show
29
+
@@ -0,0 +1,38 @@
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}/empty2.png")
11
+ @gosu = Gosu::Image.new(self, "#{Common::MEDIA}/gosu.png")
12
+
13
+ # put a border on the image
14
+ @img.rect 0,0, @img.width - 1, @img.height - 1
15
+
16
+ # perform some simple drawing actions
17
+ @img.line 0,0, @img.width - 1, @img.height - 1, :color => :yellow
18
+ @img.circle 400, 100, 40, :fill => true, :color => [rand, rand, rand, 1]
19
+ @img.rect 200, 300, 300, 400, :fill => true, :color => :red
20
+
21
+ @img.ngon 400,300,50, 5, :start_angle => 90
22
+ @img.ngon 300,300,50, 5, :start_angle => 45
23
+
24
+ # NOTE: chroma_key means NOT to splice in that color (pixels with that color are skipped)
25
+ # (chroma_key_not does the opposite, it skips pixels that do NOT have that color)
26
+ @img.splice @gosu, 210, 330, :chroma_key => :alpha
27
+ end
28
+
29
+ def draw
30
+ @img.draw 100, 50,1
31
+ end
32
+
33
+ end
34
+
35
+
36
+ w = W.new
37
+ w.show
38
+
@@ -0,0 +1,27 @@
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}/texplay.png")
10
+ @gosu = Gosu::Image.new(self, "#{Common::MEDIA}/gosu.png")
11
+
12
+ @img.splice @gosu, 140,20, :alpha_blend => true
13
+ @img.rect 140,20, 160, 180, :color => [1,1,1,0.5], :alpha_blend => true, :fill => true
14
+
15
+ @img.splice @gosu, 50,20, :chroma_key => :alpha
16
+ end
17
+
18
+ def draw
19
+ @img.draw 100, 50,1
20
+ end
21
+
22
+ end
23
+
24
+
25
+ w = W.new
26
+ w.show
27
+
@@ -0,0 +1,60 @@
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
+ # sets the 'global' color for all actions in this image
12
+ @img.color :red
13
+
14
+ # let's draw the circle without syncing it to gl
15
+ @img.circle 100, 100, 50, :fill => true, :sync_mode => :no_sync
16
+
17
+ # now let's sync half of it to gl
18
+ @img.force_sync [100, 50, 150, 150]
19
+
20
+ # let's draw some lazy shapes
21
+ @img.set_options :sync_mode => :lazy_sync
22
+
23
+ @img.ngon 200, 300, 40, 5, :color => :red
24
+ @img.ngon 280, 300, 40, 6, :color => :green
25
+ @img.ngon 360, 300, 40, 7, :color => :blue
26
+
27
+ # now let's sync the lazy shapes to gl
28
+ @img.paint
29
+
30
+ # NOTE: the lazy drawing (above) is identical to using the following paint block
31
+ # @img.paint {
32
+ # ngon 200, 300, 50, 5
33
+ # ...etc
34
+ # }
35
+
36
+ # end lazy drawing mode
37
+ @img.delete_options
38
+
39
+ # the default sync mode is eager_sync
40
+ # in this mode actions are drawn and sync'd immediately
41
+ # NOTE: TexPlay only syncs the part of the image that changed to gl
42
+ @img.ngon 440, 300, 40, 8, :color => :tyrian
43
+
44
+ # paint blocks can also accept a sync_mode parameter
45
+ # NOTE: the line below will not be visible until you
46
+ # explictly sync it to gl; probably using @img.force_sync
47
+ @img.paint(:sync_mode => :no_sync) {
48
+ line 0, 0, @img.width, @img.height
49
+ }
50
+ end
51
+
52
+ def draw
53
+
54
+ @img.draw 100, 50,1
55
+ end
56
+ end
57
+
58
+ w = W.new
59
+ w.show
60
+
@@ -0,0 +1,40 @@
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
+
18
+ # NOTE: turtle is currently written in Ruby so is very slow, look at texplay-contrib.rb for source code.
19
+ def draw
20
+
21
+ # NOTE: putting actions in paint block means they are only sync'd to gl at end of block.
22
+ # compare to calling an action directly (on an @img) where it is sync'd to gl immediately
23
+
24
+ @img.paint {
25
+
26
+ # a 2nd arg of 'true' means to show the turtle
27
+ forward(@length, true, :color => :red)
28
+ turn(89.5)
29
+ @length += 2
30
+ }
31
+
32
+ @img.draw 100, 50,1
33
+ end
34
+
35
+ end
36
+
37
+
38
+ w = W.new
39
+ w.show
40
+
@@ -0,0 +1,29 @@
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}/bird.png")
10
+ @green = Gosu::Image.new(self, "#{Common::MEDIA}/gob.png")
11
+ ### @img = Gosu::Image.new(self, "gob.png")
12
+ #@img = TexPlay.create_image(self, 500, 500).fill(0,0, :color => :red)
13
+
14
+ @img.splice @green, 0, 0, :alpha_blend => true
15
+ puts @img.get_pixel 15, 15
16
+ # @img.rect 0, 0, @img.width, @img.height, :texture => @gob, :fill => true, :alpha_blend => true
17
+
18
+ end
19
+
20
+ def draw
21
+ @img.draw 100, 50,1
22
+ end
23
+
24
+ end
25
+
26
+
27
+ w = W.new
28
+ w.show
29
+
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -1,3 +1,3 @@
1
1
  module TexPlay
2
- VERSION = "0.2.720"
2
+ VERSION = "0.2.721"
3
3
  end
metadata CHANGED
@@ -1,7 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: texplay
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.720
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 2
8
+ - 721
9
+ version: 0.2.721
5
10
  platform: i386-mswin32
6
11
  authors:
7
12
  - John Mair (banisterfiend)
@@ -14,14 +19,18 @@ default_executable:
14
19
  dependencies:
15
20
  - !ruby/object:Gem::Dependency
16
21
  name: gosu
17
- type: :runtime
18
- version_requirement:
19
- version_requirements: !ruby/object:Gem::Requirement
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
20
24
  requirements:
21
25
  - - ">="
22
26
  - !ruby/object:Gem::Version
27
+ segments:
28
+ - 0
29
+ - 7
30
+ - 14
23
31
  version: 0.7.14
24
- version:
32
+ type: :runtime
33
+ version_requirements: *id001
25
34
  description: TexPlay is a light-weight image manipulation framework for Ruby and Gosu
26
35
  email: jrmair@gmail.com
27
36
  executables: []
@@ -39,6 +48,39 @@ files:
39
48
  - lib/texplay/version.rb
40
49
  - lib/1.8/texplay.so
41
50
  - lib/1.9/texplay.so
51
+ - examples/common.rb
52
+ - examples/example_alpha_blend.rb
53
+ - examples/example_bezier.rb
54
+ - examples/example_color_control.rb
55
+ - examples/example_color_transform.rb
56
+ - examples/example_dup.rb
57
+ - examples/example_each.rb
58
+ - examples/example_effect.rb
59
+ - examples/example_fill.rb
60
+ - examples/example_fill_old.rb
61
+ - examples/example_fluent.rb
62
+ - examples/example_gen_eval.rb
63
+ - examples/example_hash_arguments.rb
64
+ - examples/example_lsystem.rb
65
+ - examples/example_melt.rb
66
+ - examples/example_polyline.rb
67
+ - examples/example_scale.rb
68
+ - examples/example_simple.rb
69
+ - examples/example_splice.rb
70
+ - examples/example_sync.rb
71
+ - examples/example_turtle.rb
72
+ - examples/example_weird.rb
73
+ - examples/media/bird.png
74
+ - examples/media/empty2.png
75
+ - examples/media/gob.png
76
+ - examples/media/gosu.png
77
+ - examples/media/green.png
78
+ - examples/media/logo.png
79
+ - examples/media/maria.png
80
+ - examples/media/rose.bmp
81
+ - examples/media/sand1.png
82
+ - examples/media/sunset.png
83
+ - examples/media/texplay.png
42
84
  has_rdoc: true
43
85
  homepage: http://banisterfiend.wordpress.com/2008/08/23/texplay-an-image-manipulation-tool-for-ruby-and-gosu/
44
86
  licenses: []
@@ -52,18 +94,20 @@ required_ruby_version: !ruby/object:Gem::Requirement
52
94
  requirements:
53
95
  - - ">="
54
96
  - !ruby/object:Gem::Version
97
+ segments:
98
+ - 0
55
99
  version: "0"
56
- version:
57
100
  required_rubygems_version: !ruby/object:Gem::Requirement
58
101
  requirements:
59
102
  - - ">="
60
103
  - !ruby/object:Gem::Version
104
+ segments:
105
+ - 0
61
106
  version: "0"
62
- version:
63
107
  requirements: []
64
108
 
65
109
  rubyforge_project:
66
- rubygems_version: 1.3.5
110
+ rubygems_version: 1.3.6
67
111
  signing_key:
68
112
  specification_version: 3
69
113
  summary: TexPlay is a light-weight image manipulation framework for Ruby and Gosu