texplay 0.3.5 → 0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +222 -222
- data/README.markdown +43 -43
- data/Rakefile +3 -99
- data/examples/common.rb +18 -18
- data/examples/example_alpha_blend.rb +29 -29
- data/examples/example_bezier.rb +41 -41
- data/examples/example_blank.rb +37 -37
- data/examples/example_cache.rb +21 -21
- data/examples/example_color_control.rb +69 -69
- data/examples/example_color_transform.rb +62 -62
- data/examples/example_color_transform_circle.rb +34 -34
- data/examples/example_darken.rb +24 -24
- data/examples/example_dup.rb +73 -73
- data/examples/example_each.rb +39 -39
- data/examples/example_effect.rb +34 -34
- data/examples/example_fill.rb +43 -43
- data/examples/example_fill_old.rb +48 -48
- data/examples/example_fluent.rb +29 -29
- data/examples/example_font.rb +31 -31
- data/examples/example_hash_arguments.rb +46 -46
- data/examples/example_ippa.rb +23 -23
- data/examples/example_light.rb +75 -75
- data/examples/example_light_multiply.rb +18 -18
- data/examples/example_lsystem.rb +61 -61
- data/examples/example_melt.rb +25 -25
- data/examples/example_meyet.rb +62 -62
- data/examples/example_polyline.rb +42 -42
- data/examples/example_scale.rb +27 -27
- data/examples/example_select.rb +36 -36
- data/examples/example_select2.rb +25 -25
- data/examples/example_simple.rb +46 -46
- data/examples/example_splice.rb +26 -26
- data/examples/example_sync.rb +59 -59
- data/examples/example_tiles.rb +41 -41
- data/examples/example_trace.rb +22 -22
- data/examples/example_transparent.rb +28 -28
- data/examples/example_transparent2.rb +24 -24
- data/examples/example_transparent3.rb +20 -20
- data/examples/example_turtle.rb +39 -39
- data/examples/example_weird.rb +22 -22
- data/examples/example_window_render_to_image.rb +41 -41
- data/examples/example_window_to_blob.rb +35 -35
- data/examples/media/maria.png +0 -0
- data/examples/media/rose.bmp +0 -0
- data/ext/texplay/actions.c +1006 -1006
- data/ext/texplay/actions.h +60 -60
- data/ext/texplay/bindings.c +1125 -1186
- data/ext/texplay/bindings.h +46 -46
- data/ext/texplay/cache.c +118 -118
- data/ext/texplay/cache.h +24 -24
- data/ext/texplay/compat.h +27 -27
- data/ext/texplay/extconf.rb +28 -28
- data/ext/texplay/graphics_utils.c +1313 -1313
- data/ext/texplay/graphics_utils.h +22 -22
- data/ext/texplay/texplay.c +201 -216
- data/ext/texplay/texplay.h +153 -153
- data/ext/texplay/utils.c +891 -891
- data/ext/texplay/utils.h +153 -153
- data/lib/texplay-contrib.rb +147 -164
- data/lib/texplay.rb +341 -356
- data/lib/texplay/alone.rb +20 -20
- data/lib/texplay/c_function_docs.rb +178 -190
- data/lib/texplay/live.rb +84 -84
- data/lib/texplay/version.rb +3 -3
- data/live/live.rb +85 -85
- data/test/image_spec.rb +45 -45
- data/test/texplay_spec.rb +144 -141
- metadata +54 -42
- data/examples/example_gen_eval.rb +0 -32
- data/ext/texplay/gen_eval.c +0 -211
- data/ext/texplay/gen_eval.h +0 -20
- data/ext/texplay/object2module.c +0 -171
- data/ext/texplay/object2module.h +0 -11
data/examples/example_effect.rb
CHANGED
@@ -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
|
+
|
data/examples/example_fill.rb
CHANGED
@@ -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
|
+
|
data/examples/example_fluent.rb
CHANGED
@@ -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
|
+
|
data/examples/example_font.rb
CHANGED
@@ -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
|
+
|