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,34 +1,34 @@
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
- @length = 0
14
- end
15
-
16
- def draw
17
-
18
- # quite a cool effect, very slow of course, because it's using turtle and fill
19
- @img.paint {
20
- forward(@length, true, :color => :red)
21
- turn(170)
22
- @length += 5
23
- fill (@img.width * rand), (@img.height * rand), :color => :random, :glow => true
24
- }
25
-
26
- @img.draw 0, 0,1
27
- end
28
-
29
- end
30
-
31
-
32
- w = W.new
33
- w.show
34
-
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
+ @length = 0
14
+ end
15
+
16
+ def draw
17
+
18
+ # quite a cool effect, very slow of course, because it's using turtle and fill
19
+ @img.paint {
20
+ forward(@length, true, :color => :red)
21
+ turn(170)
22
+ @length += 5
23
+ fill (@img.width * rand), (@img.height * rand), :color => :random, :glow => true
24
+ }
25
+
26
+ @img.draw 0, 0,1
27
+ end
28
+
29
+ end
30
+
31
+
32
+ w = W.new
33
+ w.show
34
+
@@ -1,43 +1,43 @@
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 = TexPlay::create_blank_image(self, 1022, 800)
9
- @tp = Gosu::Image.new(self, "#{Common::MEDIA}/texplay.png")
10
- @gosu = Gosu::Image.new(self, "#{Common::MEDIA}/sand1.png")
11
-
12
- points = []
13
-
14
- # NOTE: TexPlay also accepts points. a 'point' is any object that responds to 'x' or y
15
- # NOTE: current maximum points for a bezier is 13
16
- (0..@img.width + 90).step(185) { |x|
17
- p = TexPlay::TPPoint.new
18
- p.x = x
19
- p.y = @img.height * rand
20
-
21
- points << p
22
- }
23
-
24
- @img.bezier points
25
-
26
- # NOTE: the :texture hash argument works on ALL drawing actions; not just fills
27
- @img.fill 300, 650, :texture => @gosu
28
-
29
- # let's demonstrate by drawing a circle using the gosu.png texture
30
- # NOTE: :texture even works on lines, boxes, polylines, beziers etc.
31
- @img.circle 400, 50, 40, :fill => true, :texture => @tp
32
- end
33
-
34
- def draw
35
- @img.draw 0, 0,1
36
- end
37
-
38
- end
39
-
40
-
41
- w = W.new
42
- w.show
43
-
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 = TexPlay::create_blank_image(self, 1022, 800)
9
+ @tp = Gosu::Image.new(self, "#{Common::MEDIA}/texplay.png")
10
+ @gosu = Gosu::Image.new(self, "#{Common::MEDIA}/sand1.png")
11
+
12
+ points = []
13
+
14
+ # NOTE: TexPlay also accepts points. a 'point' is any object that responds to 'x' or y
15
+ # NOTE: current maximum points for a bezier is 13
16
+ (0..@img.width + 90).step(185) { |x|
17
+ p = TexPlay::TPPoint.new
18
+ p.x = x
19
+ p.y = @img.height * rand
20
+
21
+ points << p
22
+ }
23
+
24
+ @img.bezier points
25
+
26
+ # NOTE: the :texture hash argument works on ALL drawing actions; not just fills
27
+ @img.fill 300, 650, :texture => @gosu
28
+
29
+ # let's demonstrate by drawing a circle using the gosu.png texture
30
+ # NOTE: :texture even works on lines, boxes, polylines, beziers etc.
31
+ @img.circle 400, 50, 40, :fill => true, :texture => @tp
32
+ end
33
+
34
+ def draw
35
+ @img.draw 0, 0,1
36
+ end
37
+
38
+ end
39
+
40
+
41
+ w = W.new
42
+ w.show
43
+
@@ -1,48 +1,48 @@
1
- $LOAD_PATH.unshift File.dirname(File.expand_path(__FILE__))
2
- require 'common'
3
-
4
- class W < Gosu::Window
5
- def initialize
6
- super(500, 500, false, 20)
7
- @img = Gosu::Image.new(self, "#{Common::MEDIA}/empty2.png")
8
- @tp = Gosu::Image.new(self, "#{Common::MEDIA}/texplay.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
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).step(50) { |x|
19
- p = TexPlay::TPPoint.new
20
- p.x = x
21
- p.y = @img.height * rand
22
-
23
- points << p
24
- }
25
-
26
- @img.bezier points, :color => :white
27
-
28
-
29
- # NOTE: the :texture hash argument works on ALL drawing actions; not just fills
30
- @img.fill 300, 480, :texture => @tp
31
-
32
- # let's demonstrate by drawing a circle using the gosu.png texture
33
- # NOTE: :texture even works on lines, boxes, polylines, beziers etc.
34
- @img.circle 400, 50, 40, :fill => true, :texture => @gosu
35
-
36
- end
37
-
38
- def draw
39
-
40
- @img.draw 0, 0,1
41
- end
42
-
43
- end
44
-
45
-
46
- w = W.new
47
- w.show
48
-
1
+ $LOAD_PATH.unshift File.dirname(File.expand_path(__FILE__))
2
+ require 'common'
3
+
4
+ class W < Gosu::Window
5
+ def initialize
6
+ super(500, 500, false, 20)
7
+ @img = Gosu::Image.new(self, "#{Common::MEDIA}/empty2.png")
8
+ @tp = Gosu::Image.new(self, "#{Common::MEDIA}/texplay.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
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).step(50) { |x|
19
+ p = TexPlay::TPPoint.new
20
+ p.x = x
21
+ p.y = @img.height * rand
22
+
23
+ points << p
24
+ }
25
+
26
+ @img.bezier points, :color => :white
27
+
28
+
29
+ # NOTE: the :texture hash argument works on ALL drawing actions; not just fills
30
+ @img.fill 300, 480, :texture => @tp
31
+
32
+ # let's demonstrate by drawing a circle using the gosu.png texture
33
+ # NOTE: :texture even works on lines, boxes, polylines, beziers etc.
34
+ @img.circle 400, 50, 40, :fill => true, :texture => @gosu
35
+
36
+ end
37
+
38
+ def draw
39
+
40
+ @img.draw 0, 0,1
41
+ end
42
+
43
+ end
44
+
45
+
46
+ w = W.new
47
+ w.show
48
+
@@ -1,29 +1,29 @@
1
- $LOAD_PATH.unshift File.dirname(File.expand_path(__FILE__))
2
- require 'common'
3
-
4
- class W < Gosu::Window
5
- def initialize
6
- super(500, 500, false, 20)
7
- @img = Gosu::Image.new(self, "#{Common::MEDIA}/sunset.png")
8
- @img.rect 0,0, @img.width - 1, @img.height - 1
9
-
10
- # test the fluent interface
11
- @img.
12
- line(0, 0, 1024, 1024).
13
- circle(20, 20, 50).
14
- rect 30, 30, 100, 100
15
- end
16
-
17
- def draw
18
- x = @img.width * rand
19
- y = @img.height * rand
20
-
21
- @img.draw 100, 50,1
22
- end
23
-
24
- end
25
-
26
-
27
- w = W.new
28
- w.show
29
-
1
+ $LOAD_PATH.unshift File.dirname(File.expand_path(__FILE__))
2
+ require 'common'
3
+
4
+ class W < Gosu::Window
5
+ def initialize
6
+ super(500, 500, false, 20)
7
+ @img = Gosu::Image.new(self, "#{Common::MEDIA}/sunset.png")
8
+ @img.rect 0,0, @img.width - 1, @img.height - 1
9
+
10
+ # test the fluent interface
11
+ @img.
12
+ line(0, 0, 1024, 1024).
13
+ circle(20, 20, 50).
14
+ rect 30, 30, 100, 100
15
+ end
16
+
17
+ def draw
18
+ x = @img.width * rand
19
+ y = @img.height * rand
20
+
21
+ @img.draw 100, 50,1
22
+ end
23
+
24
+ end
25
+
26
+
27
+ w = W.new
28
+ w.show
29
+
@@ -1,31 +1,31 @@
1
- $LOAD_PATH.unshift File.dirname(File.expand_path(__FILE__))
2
- require 'common'
3
-
4
-
5
-
6
- # TEST_CASE 1 shows 2 pieces of text, but the background is black, even with :chroma_key. TEST_CASE 2 shows nothing.
7
- # However, if you remove the :chroma_key's, you see a black background (and no text) in TEST_CASE 2, so there, :chroma_key appears to work.
8
-
9
- class Wnd < Gosu::Window
10
- def initialize
11
- super(500, 200, false)
12
- self.caption = "Splice Issues"
13
-
14
- @chrome = TexPlay::create_blank_image(self, 200, 200)
15
- @sunset = Gosu::Image.new(self, "#{Common::MEDIA}/sand1.png")
16
-
17
-
18
- @long_text = Gosu::Image.from_text(self, "This is a long piece of text..", Gosu::default_font_name, 60)
19
- @chrome.splice @long_text, 0, 0
20
-
21
- @chrome.rect 0,0, @chrome.width, @chrome.height, :texture => @sunset, :fill => true, :mode => :multiply
22
-
23
- end
24
-
25
- def draw
26
- @chrome.draw(0,0,1)
27
- end
28
- end
29
-
30
- Wnd.new.show
31
-
1
+ $LOAD_PATH.unshift File.dirname(File.expand_path(__FILE__))
2
+ require 'common'
3
+
4
+
5
+
6
+ # TEST_CASE 1 shows 2 pieces of text, but the background is black, even with :chroma_key. TEST_CASE 2 shows nothing.
7
+ # However, if you remove the :chroma_key's, you see a black background (and no text) in TEST_CASE 2, so there, :chroma_key appears to work.
8
+
9
+ class Wnd < Gosu::Window
10
+ def initialize
11
+ super(500, 200, false)
12
+ self.caption = "Splice Issues"
13
+
14
+ @chrome = TexPlay::create_blank_image(self, 200, 200)
15
+ @sunset = Gosu::Image.new(self, "#{Common::MEDIA}/sand1.png")
16
+
17
+
18
+ @long_text = Gosu::Image.from_text(self, "This is a long piece of text..", Gosu::default_font_name, 60)
19
+ @chrome.splice @long_text, 0, 0
20
+
21
+ @chrome.rect 0,0, @chrome.width, @chrome.height, :texture => @sunset, :fill => true, :mode => :multiply
22
+
23
+ end
24
+
25
+ def draw
26
+ @chrome.draw(0,0,1)
27
+ end
28
+ end
29
+
30
+ Wnd.new.show
31
+
@@ -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
- @tp = Gosu::Image.new(self, "#{Common::MEDIA}/texplay.png")
10
-
11
-
12
- # put a border on the image
13
- @img.rect 0,0, @img.width - 1, @img.height - 1
14
-
15
- # it can be annoying having to specify a bunch of :hash_arguments for every action
16
- # here is how you specify common hash args that all actions will use (in the same image)
17
-
18
- # all actions that respond to 'thickness' use a thickness of 8 pixels
19
- # also set the color to random
20
- @img.set_options :thickness => 8, :color => :rand
21
-
22
- @img.rect 100, 100, 200, 200, :fill => false
23
-
24
- # NOTE: for ngon, the parameters are as follows: x, y, radius, num_sides
25
- @img.ngon 400, 400, 40, 3
26
-
27
- # NOTE: the defaults can also be overidden:
28
- @img.ngon 400, 200, 90, 6, :thickness => 1
29
-
30
- # you can also delete the defaults
31
- @img.delete_options
32
-
33
- # this action will no longer have any default values
34
- @img.ngon 200, 400, 90, 10
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
+ @tp = Gosu::Image.new(self, "#{Common::MEDIA}/texplay.png")
10
+
11
+
12
+ # put a border on the image
13
+ @img.rect 0,0, @img.width - 1, @img.height - 1
14
+
15
+ # it can be annoying having to specify a bunch of :hash_arguments for every action
16
+ # here is how you specify common hash args that all actions will use (in the same image)
17
+
18
+ # all actions that respond to 'thickness' use a thickness of 8 pixels
19
+ # also set the color to random
20
+ @img.set_options :thickness => 8, :color => :rand
21
+
22
+ @img.rect 100, 100, 200, 200, :fill => false
23
+
24
+ # NOTE: for ngon, the parameters are as follows: x, y, radius, num_sides
25
+ @img.ngon 400, 400, 40, 3
26
+
27
+ # NOTE: the defaults can also be overidden:
28
+ @img.ngon 400, 200, 90, 6, :thickness => 1
29
+
30
+ # you can also delete the defaults
31
+ @img.delete_options
32
+
33
+ # this action will no longer have any default values
34
+ @img.ngon 200, 400, 90, 10
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
+