texplay 0.4.3 → 0.4.4.pre

Sign up to get free protection for your applications and to get access to all the features.
Files changed (71) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG +225 -222
  3. data/README.markdown +48 -48
  4. data/Rakefile +16 -16
  5. data/examples/common.rb +18 -18
  6. data/examples/example_alpha_blend.rb +29 -29
  7. data/examples/example_bezier.rb +41 -41
  8. data/examples/example_blank.rb +37 -37
  9. data/examples/example_cache.rb +21 -21
  10. data/examples/example_color_control.rb +69 -69
  11. data/examples/example_color_transform.rb +62 -62
  12. data/examples/example_color_transform_circle.rb +34 -34
  13. data/examples/example_darken.rb +24 -24
  14. data/examples/example_dup.rb +73 -73
  15. data/examples/example_each.rb +39 -39
  16. data/examples/example_effect.rb +34 -34
  17. data/examples/example_fill.rb +43 -43
  18. data/examples/example_fill_old.rb +48 -48
  19. data/examples/example_fluent.rb +29 -29
  20. data/examples/example_font.rb +31 -31
  21. data/examples/example_hash_arguments.rb +46 -46
  22. data/examples/example_ippa.rb +23 -23
  23. data/examples/example_light.rb +75 -75
  24. data/examples/example_light_multiply.rb +18 -18
  25. data/examples/example_lsystem.rb +61 -61
  26. data/examples/example_melt.rb +25 -25
  27. data/examples/example_meyet.rb +62 -62
  28. data/examples/example_polyline.rb +42 -42
  29. data/examples/example_scale.rb +27 -27
  30. data/examples/example_select.rb +36 -36
  31. data/examples/example_select2.rb +25 -25
  32. data/examples/example_simple.rb +46 -46
  33. data/examples/example_splice.rb +26 -26
  34. data/examples/example_sync.rb +59 -59
  35. data/examples/example_tiles.rb +41 -41
  36. data/examples/example_trace.rb +22 -22
  37. data/examples/example_transparent.rb +28 -28
  38. data/examples/example_transparent2.rb +24 -24
  39. data/examples/example_transparent3.rb +20 -20
  40. data/examples/example_turtle.rb +39 -39
  41. data/examples/example_weird.rb +22 -22
  42. data/examples/example_window_render_to_image.rb +41 -41
  43. data/examples/example_window_to_blob.rb +35 -35
  44. data/examples/media/maria.png +0 -0
  45. data/examples/media/rose.bmp +0 -0
  46. data/ext/texplay/actions.c +1011 -1006
  47. data/ext/texplay/actions.h +60 -60
  48. data/ext/texplay/bindings.c +1130 -1125
  49. data/ext/texplay/bindings.h +46 -46
  50. data/ext/texplay/cache.c +123 -118
  51. data/ext/texplay/cache.h +24 -24
  52. data/ext/texplay/compat.h +21 -27
  53. data/ext/texplay/extconf.rb +38 -38
  54. data/ext/texplay/graphics_utils.c +1318 -1313
  55. data/ext/texplay/graphics_utils.h +22 -22
  56. data/ext/texplay/texplay.c +206 -201
  57. data/ext/texplay/texplay.h +153 -153
  58. data/ext/texplay/utils.c +896 -891
  59. data/ext/texplay/utils.h +153 -153
  60. data/lib/texplay-contrib.rb +147 -147
  61. data/lib/texplay.rb +347 -347
  62. data/lib/texplay/alone.rb +20 -20
  63. data/lib/texplay/c_function_docs.rb +178 -178
  64. data/lib/texplay/live.rb +84 -84
  65. data/lib/texplay/version.rb +3 -3
  66. data/live/live.rb +85 -85
  67. data/test/image_spec.rb +45 -45
  68. data/test/texplay_spec.rb +144 -144
  69. metadata +42 -52
  70. data/lib/texplay/1.8/texplay.so +0 -0
  71. data/lib/texplay/1.9/texplay.so +0 -0
@@ -1,42 +1,42 @@
1
- $LOAD_PATH.unshift File.dirname(File.expand_path(__FILE__))
2
- require 'common'
3
-
4
-
5
- class W < Gosu::Window
6
- def initialize
7
- super(500, 500, false, 20)
8
- @img = Gosu::Image.new(self, "#{Common::MEDIA}/empty2.png")
9
-
10
- # put a border on the image
11
- @img.rect 0,0, @img.width - 1, @img.height - 1
12
-
13
- points = []
14
-
15
- # NOTE: TexPlay also accepts points. a 'point' is any object that responds to 'x' or 'y'
16
- 10.times {
17
- p = TexPlay::TPPoint.new
18
- p.x = @img.width * rand
19
- p.y = @img.height * rand
20
-
21
- points << p
22
- }
23
-
24
-
25
- # what if we want to turn a polyline into a polygon?
26
- @img.polyline points, :closed => true, :color => :blue
27
- @img.polyline points, :color => :red
28
- end
29
-
30
- def draw
31
-
32
- # NOTE: (when viewing) the blue line is the extra line added to close the polygon,
33
- # red lines are original polyline
34
- @img.draw 0, 0,1
35
- end
36
-
37
- end
38
-
39
-
40
- w = W.new
41
- w.show
42
-
1
+ $LOAD_PATH.unshift File.dirname(File.expand_path(__FILE__))
2
+ require 'common'
3
+
4
+
5
+ class W < Gosu::Window
6
+ def initialize
7
+ super(500, 500, false, 20)
8
+ @img = Gosu::Image.new(self, "#{Common::MEDIA}/empty2.png")
9
+
10
+ # put a border on the image
11
+ @img.rect 0,0, @img.width - 1, @img.height - 1
12
+
13
+ points = []
14
+
15
+ # NOTE: TexPlay also accepts points. a 'point' is any object that responds to 'x' or 'y'
16
+ 10.times {
17
+ p = TexPlay::TPPoint.new
18
+ p.x = @img.width * rand
19
+ p.y = @img.height * rand
20
+
21
+ points << p
22
+ }
23
+
24
+
25
+ # what if we want to turn a polyline into a polygon?
26
+ @img.polyline points, :closed => true, :color => :blue
27
+ @img.polyline points, :color => :red
28
+ end
29
+
30
+ def draw
31
+
32
+ # NOTE: (when viewing) the blue line is the extra line added to close the polygon,
33
+ # red lines are original polyline
34
+ @img.draw 0, 0,1
35
+ end
36
+
37
+ end
38
+
39
+
40
+ w = W.new
41
+ w.show
42
+
@@ -1,27 +1,27 @@
1
- $LOAD_PATH.unshift File.dirname(File.expand_path(__FILE__))
2
- require 'common'
3
-
4
-
5
- class W < Gosu::Window
6
- def initialize
7
- super(500, 500, false, 20)
8
- @img = Gosu::Image.new(self, "#{Common::MEDIA}/logo.png")
9
- @img2 = TexPlay::create_blank_image(self, 500, 500)
10
-
11
- @img2.splice_and_scale @img, 0, 50, :factor => 2
12
- @img2.splice @img, 0, 200
13
- end
14
-
15
- def draw
16
- x = @img.width * rand
17
- y = @img.height * rand
18
-
19
- @img2.draw 100, 100,1
20
- end
21
-
22
- end
23
-
24
-
25
- w = W.new
26
- w.show
27
-
1
+ $LOAD_PATH.unshift File.dirname(File.expand_path(__FILE__))
2
+ require 'common'
3
+
4
+
5
+ class W < Gosu::Window
6
+ def initialize
7
+ super(500, 500, false, 20)
8
+ @img = Gosu::Image.new(self, "#{Common::MEDIA}/logo.png")
9
+ @img2 = TexPlay::create_blank_image(self, 500, 500)
10
+
11
+ @img2.splice_and_scale @img, 0, 50, :factor => 2
12
+ @img2.splice @img, 0, 200
13
+ end
14
+
15
+ def draw
16
+ x = @img.width * rand
17
+ y = @img.height * rand
18
+
19
+ @img2.draw 100, 100,1
20
+ end
21
+
22
+ end
23
+
24
+
25
+ w = W.new
26
+ w.show
27
+
@@ -1,36 +1,36 @@
1
- $LOAD_PATH.unshift File.dirname(File.expand_path(__FILE__))
2
- require 'common'
3
-
4
-
5
- class W < Gosu::Window
6
- def initialize
7
- super(500, 500, false, 20)
8
-
9
- # draw a filled rect with left region blue, and right region red
10
- # at top and yellow at bottom
11
- @img = TexPlay.create_image(self, 500, 500, :color => Gosu::Color::BLUE)
12
- @img.rect 250,0, 500, 500, :color => :red, :fill => true
13
- @img.rect 250, 250, 500, 500, :color => :yellow, :fill => true
14
-
15
- # base rect is green on left and purple on right
16
- @base = TexPlay.create_image(self, 500, 500, :color => :green)
17
- @base.rect 250,0, 500, 500, :color => :purple, :fill => true
18
-
19
- # splice @img into @base, and select the yellow part of @img to
20
- # go into the purple part of @base
21
- # a combination of source_select
22
- # and dest_select - filtering both source and destination pixels
23
- @base.splice @img, 0, 0, :dest_select => :purple, :source_select => :yellow
24
-
25
- end
26
-
27
- def draw
28
- @base.draw 0, 0,1
29
- end
30
-
31
- end
32
-
33
-
34
- w = W.new
35
- w.show
36
-
1
+ $LOAD_PATH.unshift File.dirname(File.expand_path(__FILE__))
2
+ require 'common'
3
+
4
+
5
+ class W < Gosu::Window
6
+ def initialize
7
+ super(500, 500, false, 20)
8
+
9
+ # draw a filled rect with left region blue, and right region red
10
+ # at top and yellow at bottom
11
+ @img = TexPlay.create_image(self, 500, 500, :color => Gosu::Color::BLUE)
12
+ @img.rect 250,0, 500, 500, :color => :red, :fill => true
13
+ @img.rect 250, 250, 500, 500, :color => :yellow, :fill => true
14
+
15
+ # base rect is green on left and purple on right
16
+ @base = TexPlay.create_image(self, 500, 500, :color => :green)
17
+ @base.rect 250,0, 500, 500, :color => :purple, :fill => true
18
+
19
+ # splice @img into @base, and select the yellow part of @img to
20
+ # go into the purple part of @base
21
+ # a combination of source_select
22
+ # and dest_select - filtering both source and destination pixels
23
+ @base.splice @img, 0, 0, :dest_select => :purple, :source_select => :yellow
24
+
25
+ end
26
+
27
+ def draw
28
+ @base.draw 0, 0,1
29
+ end
30
+
31
+ end
32
+
33
+
34
+ w = W.new
35
+ w.show
36
+
@@ -1,25 +1,25 @@
1
- $LOAD_PATH.unshift File.dirname(File.expand_path(__FILE__))
2
- require 'common'
3
- require 'benchmark'
4
-
5
-
6
- class W < Gosu::Window
7
- def initialize
8
- super(500, 500, false, 20)
9
- @img = Gosu::Image.new(self, "#{Common::MEDIA}/sunset.png")
10
- @maria = Gosu::Image.new(self, "#{Common::MEDIA}/maria.png")
11
- @img.rect 0,0, @img.width - 1, @img.height - 1
12
- @img.splice @maria, 0, 0, :tolerance => 0.70, :source_select => [:brown,:yellow], :crop => [200, 50, 500, 800]
13
-
14
- end
15
-
16
- def draw
17
- @img.draw 0, 0,1
18
- end
19
-
20
- end
21
-
22
-
23
- w = W.new
24
- w.show
25
-
1
+ $LOAD_PATH.unshift File.dirname(File.expand_path(__FILE__))
2
+ require 'common'
3
+ require 'benchmark'
4
+
5
+
6
+ class W < Gosu::Window
7
+ def initialize
8
+ super(500, 500, false, 20)
9
+ @img = Gosu::Image.new(self, "#{Common::MEDIA}/sunset.png")
10
+ @maria = Gosu::Image.new(self, "#{Common::MEDIA}/maria.png")
11
+ @img.rect 0,0, @img.width - 1, @img.height - 1
12
+ @img.splice @maria, 0, 0, :tolerance => 0.70, :source_select => [:brown,:yellow], :crop => [200, 50, 500, 800]
13
+
14
+ end
15
+
16
+ def draw
17
+ @img.draw 0, 0,1
18
+ end
19
+
20
+ end
21
+
22
+
23
+ w = W.new
24
+ w.show
25
+
@@ -1,46 +1,46 @@
1
- $LOAD_PATH.unshift File.dirname(File.expand_path(__FILE__))
2
- require 'common'
3
-
4
-
5
- class W < Gosu::Window
6
- def initialize
7
- super(500, 500, false, 20)
8
- @img = Gosu::Image.new(self, "#{Common::MEDIA}/empty2.png")
9
- @gosu = Gosu::Image.new(self, "#{Common::MEDIA}/gosu.png")
10
-
11
- # put a border on the image
12
- @img.rect 0,0, @img.width - 1, @img.height - 1, :color => 0xffff00ff, :fill => true
13
-
14
- # perform some e drawing actions
15
- @img.line 0,0, @img.width - 1, @img.height - 1, :color => Gosu::Color::AQUA
16
- @img.circle 400, 100, 40, :fill => true, :color => [rand, rand, rand, 1]
17
- @img.rect 200, 300, 300, 400, :fill => true, :color => :red, :source_ignore => [:green],
18
- :color_control => proc {
19
- rand(2) == 1 ? :red : :blue
20
- }
21
-
22
- @img.ngon 400,300,50, 5, :start_angle => 90
23
- @img.ngon 300,300,50, 5, :start_angle => 45
24
-
25
- # NOTE: chroma_key means NOT to splice in that color (pixels with that color are skipped)
26
- # (chroma_key_not does the opposite, it skips pixels that do NOT have that color)
27
- @img.splice @gosu, 210, 330,
28
- :dest_select => [:blue], :source_ignore => [:alpha, :green]
29
-
30
- @img.line 200, 300, 300, 400, :thickness => 5,
31
- :dest_select => :blue, :dest_ignore => :red
32
-
33
- puts (@img.get_pixel 2000, 310).inspect
34
- puts @img.get_pixel 2000, 310, :color_mode => :gosu
35
- end
36
-
37
- def draw
38
- @img.draw 100, 50,1
39
- end
40
-
41
- end
42
-
43
-
44
- w = W.new
45
- w.show
46
-
1
+ $LOAD_PATH.unshift File.dirname(File.expand_path(__FILE__))
2
+ require 'common'
3
+
4
+
5
+ class W < Gosu::Window
6
+ def initialize
7
+ super(500, 500, false, 20)
8
+ @img = Gosu::Image.new(self, "#{Common::MEDIA}/empty2.png")
9
+ @gosu = Gosu::Image.new(self, "#{Common::MEDIA}/gosu.png")
10
+
11
+ # put a border on the image
12
+ @img.rect 0,0, @img.width - 1, @img.height - 1, :color => 0xffff00ff, :fill => true
13
+
14
+ # perform some e drawing actions
15
+ @img.line 0,0, @img.width - 1, @img.height - 1, :color => Gosu::Color::AQUA
16
+ @img.circle 400, 100, 40, :fill => true, :color => [rand, rand, rand, 1]
17
+ @img.rect 200, 300, 300, 400, :fill => true, :color => :red, :source_ignore => [:green],
18
+ :color_control => proc {
19
+ rand(2) == 1 ? :red : :blue
20
+ }
21
+
22
+ @img.ngon 400,300,50, 5, :start_angle => 90
23
+ @img.ngon 300,300,50, 5, :start_angle => 45
24
+
25
+ # NOTE: chroma_key means NOT to splice in that color (pixels with that color are skipped)
26
+ # (chroma_key_not does the opposite, it skips pixels that do NOT have that color)
27
+ @img.splice @gosu, 210, 330,
28
+ :dest_select => [:blue], :source_ignore => [:alpha, :green]
29
+
30
+ @img.line 200, 300, 300, 400, :thickness => 5,
31
+ :dest_select => :blue, :dest_ignore => :red
32
+
33
+ puts (@img.get_pixel 2000, 310).inspect
34
+ puts @img.get_pixel 2000, 310, :color_mode => :gosu
35
+ end
36
+
37
+ def draw
38
+ @img.draw 100, 50,1
39
+ end
40
+
41
+ end
42
+
43
+
44
+ w = W.new
45
+ w.show
46
+
@@ -1,26 +1,26 @@
1
- $LOAD_PATH.unshift File.dirname(File.expand_path(__FILE__))
2
- require 'common'
3
-
4
-
5
- class W < Gosu::Window
6
- def initialize
7
- super(500, 500, false, 20)
8
- @img = Gosu::Image.new(self, "#{Common::MEDIA}/texplay.png")
9
- @gosu = Gosu::Image.new(self, "#{Common::MEDIA}/gosu.png")
10
-
11
- @img.splice @gosu, 140,20, :alpha_blend => true, :mode => :default
12
- @img.rect 140,20, 160, 180, :color => [1,1,1,0.5], :alpha_blend => true, :fill => true
13
-
14
- @img.splice @gosu, 50,20, :chroma_key => :alpha
15
- end
16
-
17
- def draw
18
- @img.draw 100, 50,1
19
- end
20
-
21
- end
22
-
23
-
24
- w = W.new
25
- w.show
26
-
1
+ $LOAD_PATH.unshift File.dirname(File.expand_path(__FILE__))
2
+ require 'common'
3
+
4
+
5
+ class W < Gosu::Window
6
+ def initialize
7
+ super(500, 500, false, 20)
8
+ @img = Gosu::Image.new(self, "#{Common::MEDIA}/texplay.png")
9
+ @gosu = Gosu::Image.new(self, "#{Common::MEDIA}/gosu.png")
10
+
11
+ @img.splice @gosu, 140,20, :alpha_blend => true, :mode => :default
12
+ @img.rect 140,20, 160, 180, :color => [1,1,1,0.5], :alpha_blend => true, :fill => true
13
+
14
+ @img.splice @gosu, 50,20, :chroma_key => :alpha
15
+ end
16
+
17
+ def draw
18
+ @img.draw 100, 50,1
19
+ end
20
+
21
+ end
22
+
23
+
24
+ w = W.new
25
+ w.show
26
+
@@ -1,59 +1,59 @@
1
- $LOAD_PATH.unshift File.dirname(File.expand_path(__FILE__))
2
- require 'common'
3
-
4
-
5
- class W < Gosu::Window
6
- def initialize
7
- super(500, 500, false, 20)
8
- @img = Gosu::Image.new(self, "#{Common::MEDIA}/empty2.png")
9
-
10
- # sets the 'global' color for all actions in this image
11
- @img.color :red
12
-
13
- # let's draw the circle without syncing it to gl
14
- @img.circle 100, 100, 50, :fill => true, :sync_mode => :no_sync
15
-
16
- # now let's sync half of it to gl
17
- @img.force_sync [100, 50, 150, 150]
18
-
19
- # let's draw some lazy shapes
20
- @img.set_options :sync_mode => :lazy_sync
21
-
22
- @img.ngon 200, 300, 40, 5, :color => :red
23
- @img.ngon 280, 300, 40, 6, :color => :green
24
- @img.ngon 360, 300, 40, 7, :color => :blue
25
-
26
- # now let's sync the lazy shapes to gl
27
- @img.paint
28
-
29
- # NOTE: the lazy drawing (above) is identical to using the following paint block
30
- # @img.paint {
31
- # ngon 200, 300, 50, 5
32
- # ...etc
33
- # }
34
-
35
- # end lazy drawing mode
36
- @img.delete_options
37
-
38
- # the default sync mode is eager_sync
39
- # in this mode actions are drawn and sync'd immediately
40
- # NOTE: TexPlay only syncs the part of the image that changed to gl
41
- @img.ngon 440, 300, 40, 8, :color => :tyrian
42
-
43
- # paint blocks can also accept a sync_mode parameter
44
- # NOTE: the line below will not be visible until you
45
- # explictly sync it to gl; probably using @img.force_sync
46
- @img.paint(:sync_mode => :no_sync) {
47
- line 0, 0, @img.width, @img.height
48
- }
49
- end
50
-
51
- def draw
52
-
53
- @img.draw 0, 0,1
54
- end
55
- end
56
-
57
- w = W.new
58
- w.show
59
-
1
+ $LOAD_PATH.unshift File.dirname(File.expand_path(__FILE__))
2
+ require 'common'
3
+
4
+
5
+ class W < Gosu::Window
6
+ def initialize
7
+ super(500, 500, false, 20)
8
+ @img = Gosu::Image.new(self, "#{Common::MEDIA}/empty2.png")
9
+
10
+ # sets the 'global' color for all actions in this image
11
+ @img.color :red
12
+
13
+ # let's draw the circle without syncing it to gl
14
+ @img.circle 100, 100, 50, :fill => true, :sync_mode => :no_sync
15
+
16
+ # now let's sync half of it to gl
17
+ @img.force_sync [100, 50, 150, 150]
18
+
19
+ # let's draw some lazy shapes
20
+ @img.set_options :sync_mode => :lazy_sync
21
+
22
+ @img.ngon 200, 300, 40, 5, :color => :red
23
+ @img.ngon 280, 300, 40, 6, :color => :green
24
+ @img.ngon 360, 300, 40, 7, :color => :blue
25
+
26
+ # now let's sync the lazy shapes to gl
27
+ @img.paint
28
+
29
+ # NOTE: the lazy drawing (above) is identical to using the following paint block
30
+ # @img.paint {
31
+ # ngon 200, 300, 50, 5
32
+ # ...etc
33
+ # }
34
+
35
+ # end lazy drawing mode
36
+ @img.delete_options
37
+
38
+ # the default sync mode is eager_sync
39
+ # in this mode actions are drawn and sync'd immediately
40
+ # NOTE: TexPlay only syncs the part of the image that changed to gl
41
+ @img.ngon 440, 300, 40, 8, :color => :tyrian
42
+
43
+ # paint blocks can also accept a sync_mode parameter
44
+ # NOTE: the line below will not be visible until you
45
+ # explictly sync it to gl; probably using @img.force_sync
46
+ @img.paint(:sync_mode => :no_sync) {
47
+ line 0, 0, @img.width, @img.height
48
+ }
49
+ end
50
+
51
+ def draw
52
+
53
+ @img.draw 0, 0,1
54
+ end
55
+ end
56
+
57
+ w = W.new
58
+ w.show
59
+