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.
- checksums.yaml +7 -0
- data/CHANGELOG +225 -222
- data/README.markdown +48 -48
- data/Rakefile +16 -16
- 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 +1011 -1006
- data/ext/texplay/actions.h +60 -60
- data/ext/texplay/bindings.c +1130 -1125
- data/ext/texplay/bindings.h +46 -46
- data/ext/texplay/cache.c +123 -118
- data/ext/texplay/cache.h +24 -24
- data/ext/texplay/compat.h +21 -27
- data/ext/texplay/extconf.rb +38 -38
- data/ext/texplay/graphics_utils.c +1318 -1313
- data/ext/texplay/graphics_utils.h +22 -22
- data/ext/texplay/texplay.c +206 -201
- data/ext/texplay/texplay.h +153 -153
- data/ext/texplay/utils.c +896 -891
- data/ext/texplay/utils.h +153 -153
- data/lib/texplay-contrib.rb +147 -147
- data/lib/texplay.rb +347 -347
- data/lib/texplay/alone.rb +20 -20
- data/lib/texplay/c_function_docs.rb +178 -178
- 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 -144
- metadata +42 -52
- data/lib/texplay/1.8/texplay.so +0 -0
- data/lib/texplay/1.9/texplay.so +0 -0
@@ -1,62 +1,62 @@
|
|
1
|
-
$LOAD_PATH.unshift File.dirname(File.expand_path(__FILE__))
|
2
|
-
require 'common'
|
3
|
-
#require 'devil/gosu'
|
4
|
-
|
5
|
-
class W < Gosu::Window
|
6
|
-
def initialize
|
7
|
-
super(500, 500, false, 20)
|
8
|
-
@img = Gosu::Image.new(self, "#{Common::MEDIA}/sunset.png")
|
9
|
-
@x = 100
|
10
|
-
@y = 100
|
11
|
-
|
12
|
-
@x2 = 400
|
13
|
-
@y2 = 100
|
14
|
-
@rad = 70
|
15
|
-
@s = true
|
16
|
-
|
17
|
-
@copy = TexPlay.create_image(self, @rad * 2 + 1, @rad * 2 + 1)
|
18
|
-
@copy2 = TexPlay.create_image(self, @rad * 2 + 1, @rad * 2 + 1)
|
19
|
-
end
|
20
|
-
|
21
|
-
def draw
|
22
|
-
@pause = true
|
23
|
-
|
24
|
-
@x += 1
|
25
|
-
@y += 1
|
26
|
-
|
27
|
-
@x2 -= 1
|
28
|
-
@y2 += 1
|
29
|
-
|
30
|
-
|
31
|
-
@copy2.splice @img, 0, 0, :crop => [@x2 - @rad, @y2 - @rad, @x2 + @rad, @y2 + @rad], :sync_mode => :no_sync
|
32
|
-
@copy.splice @img, 0, 0, :crop => [@x - @rad, @y - @rad, @x + @rad, @y + @rad], :sync_mode => :no_sync
|
33
|
-
@img.rect @x - @rad, @y - @rad, @x + @rad, @y + @rad, :fill => true, :mode => :color_dodge, :color => 0xff888888, :alpha_blend => true
|
34
|
-
|
35
|
-
@img.rect @x2 - @rad, @y2 - @rad, @x2 + @rad, @y2 + @rad, :fill => true, :mode => :color_dodge, :color => 0xff888888
|
36
|
-
|
37
|
-
# @img.force_sync [0,0, @img.width, @img.height]
|
38
|
-
|
39
|
-
@img.draw 10, 10,1
|
40
|
-
|
41
|
-
if button_down?(Gosu::KbEscape)
|
42
|
-
IL.Enable(IL::ORIGIN_SET)
|
43
|
-
IL.OriginFunc(IL::ORIGIN_UPPER_LEFT)
|
44
|
-
# screenshot.crop(0,0, 500, 500).save("screenshot.jpg").free
|
45
|
-
exit
|
46
|
-
end
|
47
|
-
|
48
|
-
end
|
49
|
-
|
50
|
-
def update
|
51
|
-
@img.splice @copy, @x - @rad, @y - @rad if !@s
|
52
|
-
@img.splice @copy2, @x2 - @rad, @y2 - @rad if !@s
|
53
|
-
@s = nil if @s
|
54
|
-
|
55
|
-
end
|
56
|
-
|
57
|
-
end
|
58
|
-
|
59
|
-
|
60
|
-
w = W.new
|
61
|
-
w.show
|
62
|
-
|
1
|
+
$LOAD_PATH.unshift File.dirname(File.expand_path(__FILE__))
|
2
|
+
require 'common'
|
3
|
+
#require 'devil/gosu'
|
4
|
+
|
5
|
+
class W < Gosu::Window
|
6
|
+
def initialize
|
7
|
+
super(500, 500, false, 20)
|
8
|
+
@img = Gosu::Image.new(self, "#{Common::MEDIA}/sunset.png")
|
9
|
+
@x = 100
|
10
|
+
@y = 100
|
11
|
+
|
12
|
+
@x2 = 400
|
13
|
+
@y2 = 100
|
14
|
+
@rad = 70
|
15
|
+
@s = true
|
16
|
+
|
17
|
+
@copy = TexPlay.create_image(self, @rad * 2 + 1, @rad * 2 + 1)
|
18
|
+
@copy2 = TexPlay.create_image(self, @rad * 2 + 1, @rad * 2 + 1)
|
19
|
+
end
|
20
|
+
|
21
|
+
def draw
|
22
|
+
@pause = true
|
23
|
+
|
24
|
+
@x += 1
|
25
|
+
@y += 1
|
26
|
+
|
27
|
+
@x2 -= 1
|
28
|
+
@y2 += 1
|
29
|
+
|
30
|
+
|
31
|
+
@copy2.splice @img, 0, 0, :crop => [@x2 - @rad, @y2 - @rad, @x2 + @rad, @y2 + @rad], :sync_mode => :no_sync
|
32
|
+
@copy.splice @img, 0, 0, :crop => [@x - @rad, @y - @rad, @x + @rad, @y + @rad], :sync_mode => :no_sync
|
33
|
+
@img.rect @x - @rad, @y - @rad, @x + @rad, @y + @rad, :fill => true, :mode => :color_dodge, :color => 0xff888888, :alpha_blend => true
|
34
|
+
|
35
|
+
@img.rect @x2 - @rad, @y2 - @rad, @x2 + @rad, @y2 + @rad, :fill => true, :mode => :color_dodge, :color => 0xff888888
|
36
|
+
|
37
|
+
# @img.force_sync [0,0, @img.width, @img.height]
|
38
|
+
|
39
|
+
@img.draw 10, 10,1
|
40
|
+
|
41
|
+
if button_down?(Gosu::KbEscape)
|
42
|
+
IL.Enable(IL::ORIGIN_SET)
|
43
|
+
IL.OriginFunc(IL::ORIGIN_UPPER_LEFT)
|
44
|
+
# screenshot.crop(0,0, 500, 500).save("screenshot.jpg").free
|
45
|
+
exit
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
49
|
+
|
50
|
+
def update
|
51
|
+
@img.splice @copy, @x - @rad, @y - @rad if !@s
|
52
|
+
@img.splice @copy2, @x2 - @rad, @y2 - @rad if !@s
|
53
|
+
@s = nil if @s
|
54
|
+
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
58
|
+
|
59
|
+
|
60
|
+
w = W.new
|
61
|
+
w.show
|
62
|
+
|
@@ -1,34 +1,34 @@
|
|
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, 300, false, 20)
|
7
|
-
@spritesheet = Gosu::Image.new(self, "body.png", false)
|
8
|
-
@spritesheet.splice(Gosu::Image.new(self, "face.png", false), 0,0, :alpha_blend => true)
|
9
|
-
@sprite_array = Gosu::Image::load_tiles(self, @spritesheet, 40, 80, false)
|
10
|
-
end
|
11
|
-
|
12
|
-
def draw
|
13
|
-
@sprite_array[0].draw(200,200,0)
|
14
|
-
end
|
15
|
-
|
16
|
-
end
|
17
|
-
|
18
|
-
|
19
|
-
w = W.new
|
20
|
-
w.show
|
21
|
-
|
22
|
-
|
23
|
-
# require 'rubygems'
|
24
|
-
# require 'gosu'
|
25
|
-
# require 'texplay'
|
26
|
-
# class Game_Window < Gosu::Window
|
27
|
-
# def initialize
|
28
|
-
# super(500, 400, false)
|
29
|
-
# self.caption = "Image Test"
|
30
|
-
# end
|
31
|
-
|
32
|
-
# def draw
|
33
|
-
# end
|
34
|
-
# end
|
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, 300, false, 20)
|
7
|
+
@spritesheet = Gosu::Image.new(self, "body.png", false)
|
8
|
+
@spritesheet.splice(Gosu::Image.new(self, "face.png", false), 0,0, :alpha_blend => true)
|
9
|
+
@sprite_array = Gosu::Image::load_tiles(self, @spritesheet, 40, 80, false)
|
10
|
+
end
|
11
|
+
|
12
|
+
def draw
|
13
|
+
@sprite_array[0].draw(200,200,0)
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
|
18
|
+
|
19
|
+
w = W.new
|
20
|
+
w.show
|
21
|
+
|
22
|
+
|
23
|
+
# require 'rubygems'
|
24
|
+
# require 'gosu'
|
25
|
+
# require 'texplay'
|
26
|
+
# class Game_Window < Gosu::Window
|
27
|
+
# def initialize
|
28
|
+
# super(500, 400, false)
|
29
|
+
# self.caption = "Image Test"
|
30
|
+
# end
|
31
|
+
|
32
|
+
# def draw
|
33
|
+
# end
|
34
|
+
# end
|
data/examples/example_darken.rb
CHANGED
@@ -1,24 +1,24 @@
|
|
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, :color_control => { :mult => [0.25, 0.25, 0.25, 1] }, :fill => true
|
9
|
-
|
10
|
-
@img.rect 230, 240, 330, 340, :fill => true,
|
11
|
-
:color_control => { :mult => [4, 4, 4, 1] }
|
12
|
-
|
13
|
-
end
|
14
|
-
|
15
|
-
def draw
|
16
|
-
@img.draw 0, 0,1
|
17
|
-
end
|
18
|
-
|
19
|
-
end
|
20
|
-
|
21
|
-
|
22
|
-
w = W.new
|
23
|
-
w.show
|
24
|
-
|
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, :color_control => { :mult => [0.25, 0.25, 0.25, 1] }, :fill => true
|
9
|
+
|
10
|
+
@img.rect 230, 240, 330, 340, :fill => true,
|
11
|
+
:color_control => { :mult => [4, 4, 4, 1] }
|
12
|
+
|
13
|
+
end
|
14
|
+
|
15
|
+
def draw
|
16
|
+
@img.draw 0, 0,1
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
|
21
|
+
|
22
|
+
w = W.new
|
23
|
+
w.show
|
24
|
+
|
data/examples/example_dup.rb
CHANGED
@@ -1,73 +1,73 @@
|
|
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}/sunset.png")
|
9
|
-
@img.rect 0,0, @img.width - 1, @img.height - 1
|
10
|
-
|
11
|
-
# testing Gosu::Image#dup
|
12
|
-
# adding an ivar
|
13
|
-
@img.instance_variable_set(:@horse, :love)
|
14
|
-
|
15
|
-
# adding a method on the singleton
|
16
|
-
class << @img
|
17
|
-
def little
|
18
|
-
:little
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
# clone the image.
|
23
|
-
# NB #clone also copies singleton
|
24
|
-
@bunk = @img.clone
|
25
|
-
|
26
|
-
# should output :love
|
27
|
-
puts @bunk.instance_variable_get(:@horse)
|
28
|
-
|
29
|
-
# should output :little
|
30
|
-
puts @bunk.little
|
31
|
-
|
32
|
-
# add a red line to the copy to identify it
|
33
|
-
#@bunk.line 0, 0, 1024, 1024, :color => :red
|
34
|
-
|
35
|
-
@bunk.each(:region =>[200,200,350,350]) { |c,x,y| #
|
36
|
-
|
37
|
-
num_pixels = 0
|
38
|
-
total = [0, 0, 0, 0]
|
39
|
-
@bunk.circle x, y, 2,
|
40
|
-
:color_control => proc { |v|
|
41
|
-
if v
|
42
|
-
total[0] += v[0]
|
43
|
-
total[1] += v[1]
|
44
|
-
total[2] += v[2]
|
45
|
-
total[3] += v[3]
|
46
|
-
|
47
|
-
num_pixels += 1
|
48
|
-
end
|
49
|
-
:none
|
50
|
-
}
|
51
|
-
|
52
|
-
c[0] = total[0] / num_pixels.to_f
|
53
|
-
c[1] = total[1] / num_pixels.to_f
|
54
|
-
c[2] = total[2] / num_pixels.to_f
|
55
|
-
c[3] = total[3] / num_pixels.to_f
|
56
|
-
}
|
57
|
-
|
58
|
-
end
|
59
|
-
|
60
|
-
def draw
|
61
|
-
x = @img.width * rand
|
62
|
-
y = @img.height * rand
|
63
|
-
|
64
|
-
@img.draw 0, 0,1
|
65
|
-
@bunk.draw 0, 0,1
|
66
|
-
end
|
67
|
-
|
68
|
-
end
|
69
|
-
|
70
|
-
|
71
|
-
w = W.new
|
72
|
-
w.show
|
73
|
-
|
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}/sunset.png")
|
9
|
+
@img.rect 0,0, @img.width - 1, @img.height - 1
|
10
|
+
|
11
|
+
# testing Gosu::Image#dup
|
12
|
+
# adding an ivar
|
13
|
+
@img.instance_variable_set(:@horse, :love)
|
14
|
+
|
15
|
+
# adding a method on the singleton
|
16
|
+
class << @img
|
17
|
+
def little
|
18
|
+
:little
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
# clone the image.
|
23
|
+
# NB #clone also copies singleton
|
24
|
+
@bunk = @img.clone
|
25
|
+
|
26
|
+
# should output :love
|
27
|
+
puts @bunk.instance_variable_get(:@horse)
|
28
|
+
|
29
|
+
# should output :little
|
30
|
+
puts @bunk.little
|
31
|
+
|
32
|
+
# add a red line to the copy to identify it
|
33
|
+
#@bunk.line 0, 0, 1024, 1024, :color => :red
|
34
|
+
|
35
|
+
@bunk.each(:region =>[200,200,350,350]) { |c,x,y| #
|
36
|
+
|
37
|
+
num_pixels = 0
|
38
|
+
total = [0, 0, 0, 0]
|
39
|
+
@bunk.circle x, y, 2,
|
40
|
+
:color_control => proc { |v|
|
41
|
+
if v
|
42
|
+
total[0] += v[0]
|
43
|
+
total[1] += v[1]
|
44
|
+
total[2] += v[2]
|
45
|
+
total[3] += v[3]
|
46
|
+
|
47
|
+
num_pixels += 1
|
48
|
+
end
|
49
|
+
:none
|
50
|
+
}
|
51
|
+
|
52
|
+
c[0] = total[0] / num_pixels.to_f
|
53
|
+
c[1] = total[1] / num_pixels.to_f
|
54
|
+
c[2] = total[2] / num_pixels.to_f
|
55
|
+
c[3] = total[3] / num_pixels.to_f
|
56
|
+
}
|
57
|
+
|
58
|
+
end
|
59
|
+
|
60
|
+
def draw
|
61
|
+
x = @img.width * rand
|
62
|
+
y = @img.height * rand
|
63
|
+
|
64
|
+
@img.draw 0, 0,1
|
65
|
+
@bunk.draw 0, 0,1
|
66
|
+
end
|
67
|
+
|
68
|
+
end
|
69
|
+
|
70
|
+
|
71
|
+
w = W.new
|
72
|
+
w.show
|
73
|
+
|
data/examples/example_each.rb
CHANGED
@@ -1,39 +1,39 @@
|
|
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
|
-
|
9
|
-
# each can accept a block of two types of arity:
|
10
|
-
# arity 1 - yields just the pixel color
|
11
|
-
# arity 3 - yield the pixel color, and the x and y
|
12
|
-
|
13
|
-
# max out the blue component of every pixel
|
14
|
-
@img.each { |v| v[2] = 1 }
|
15
|
-
|
16
|
-
# a gradient from 0 red to 1 red
|
17
|
-
@img.each(:region => [100, 100, 200, 200]) do |c, x, y|
|
18
|
-
c[0] = (x - 100) / 100.0
|
19
|
-
end
|
20
|
-
|
21
|
-
# another gradient, this time blocking out everything except red (and alpha)
|
22
|
-
@img.each(:region => [100, 250, 200, 350]) do |c, x, y|
|
23
|
-
c[0] = (x - 100) / 100.0
|
24
|
-
c[1] = 0
|
25
|
-
c[2] = 0
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
def draw
|
30
|
-
|
31
|
-
@img.draw 0, 0,1
|
32
|
-
end
|
33
|
-
|
34
|
-
end
|
35
|
-
|
36
|
-
|
37
|
-
w = W.new
|
38
|
-
w.show
|
39
|
-
|
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
|
+
|
9
|
+
# each can accept a block of two types of arity:
|
10
|
+
# arity 1 - yields just the pixel color
|
11
|
+
# arity 3 - yield the pixel color, and the x and y
|
12
|
+
|
13
|
+
# max out the blue component of every pixel
|
14
|
+
@img.each { |v| v[2] = 1 }
|
15
|
+
|
16
|
+
# a gradient from 0 red to 1 red
|
17
|
+
@img.each(:region => [100, 100, 200, 200]) do |c, x, y|
|
18
|
+
c[0] = (x - 100) / 100.0
|
19
|
+
end
|
20
|
+
|
21
|
+
# another gradient, this time blocking out everything except red (and alpha)
|
22
|
+
@img.each(:region => [100, 250, 200, 350]) do |c, x, y|
|
23
|
+
c[0] = (x - 100) / 100.0
|
24
|
+
c[1] = 0
|
25
|
+
c[2] = 0
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def draw
|
30
|
+
|
31
|
+
@img.draw 0, 0,1
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
|
36
|
+
|
37
|
+
w = W.new
|
38
|
+
w.show
|
39
|
+
|