texplay 0.2.1-x86-mswin32-60
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +68 -0
- data/README +21 -0
- data/README1st +9 -0
- data/Rakefile +85 -0
- data/examples/basic.rb +48 -0
- data/examples/basic2.rb +37 -0
- data/examples/benchmark.rb +299 -0
- data/examples/common.rb +8 -0
- data/examples/example_alpha_blend.rb +31 -0
- data/examples/example_bezier.rb +51 -0
- data/examples/example_color_control.rb +68 -0
- data/examples/example_color_transform.rb +29 -0
- data/examples/example_dup.rb +52 -0
- data/examples/example_each.rb +42 -0
- data/examples/example_effect.rb +35 -0
- data/examples/example_fill.rb +49 -0
- data/examples/example_fill_old.rb +49 -0
- data/examples/example_fluent.rb +31 -0
- data/examples/example_gen_eval.rb +34 -0
- data/examples/example_hash_arguments.rb +47 -0
- data/examples/example_melt.rb +27 -0
- data/examples/example_polyline.rb +43 -0
- data/examples/example_simple.rb +35 -0
- data/examples/example_sync.rb +60 -0
- data/examples/example_turtle.rb +40 -0
- data/examples/media/empty2.png +0 -0
- data/examples/media/gosu.png +0 -0
- data/examples/media/maria.png +0 -0
- data/examples/media/rose.bmp +0 -0
- data/examples/media/sand1.png +0 -0
- data/examples/media/sunset.png +0 -0
- data/examples/media/texplay.png +0 -0
- data/examples/specs.rb +240 -0
- data/examples/test.rb +70 -0
- data/examples/test2.rb +72 -0
- data/lib/ctexplay.18.so +0 -0
- data/lib/ctexplay.19.so +0 -0
- data/lib/texplay-contrib.rb +77 -0
- data/lib/texplay.rb +134 -0
- data/src/Makefile +181 -0
- data/src/TAGS +286 -0
- data/src/actions.c +1306 -0
- data/src/actions.h +52 -0
- data/src/actions.obj +0 -0
- data/src/bindings.c +1081 -0
- data/src/bindings.h +45 -0
- data/src/bindings.obj +0 -0
- data/src/cache.c +132 -0
- data/src/cache.h +24 -0
- data/src/cache.obj +0 -0
- data/src/compat.h +23 -0
- data/src/ctexplay-i386-mswin32.def +2 -0
- data/src/ctexplay-i386-mswin32.exp +0 -0
- data/src/ctexplay-i386-mswin32.lib +0 -0
- data/src/ctexplay-i386-mswin32.pdb +0 -0
- data/src/ctexplay.so +0 -0
- data/src/extconf.rb +18 -0
- data/src/gen_eval.c +209 -0
- data/src/gen_eval.h +20 -0
- data/src/gen_eval.obj +0 -0
- data/src/mkmf.log +18 -0
- data/src/object2module.c +171 -0
- data/src/object2module.h +11 -0
- data/src/object2module.obj +0 -0
- data/src/texplay.c +136 -0
- data/src/texplay.h +107 -0
- data/src/texplay.obj +0 -0
- data/src/utils.c +959 -0
- data/src/utils.h +143 -0
- data/src/utils.obj +0 -0
- data/src/vc60.pdb +0 -0
- metadata +132 -0
data/CHANGELOG
ADDED
@@ -0,0 +1,68 @@
|
|
1
|
+
2/9/09
|
2
|
+
version 0.2.1
|
3
|
+
* releasing a gem for TexPlay
|
4
|
+
* bumped version number so can add add gosu 0.7.14 dependency to github gem
|
5
|
+
* hopefully gem works on both github and rubyforge
|
6
|
+
31/8/09
|
7
|
+
version 0.2.0
|
8
|
+
* added each iterator
|
9
|
+
* added alternative to proc for :color_control proc (allowing static linear transforms to pixels)
|
10
|
+
* no longer segfaulting on windows (no idea why not)
|
11
|
+
* rewrote EmptyImageStub in ruby, using philomory's code. now alot faster.
|
12
|
+
* implemented 'shadow' in terms of static :color_control pixel transform
|
13
|
+
* added more example code demonstrating each iterator (example_each.rb) and new color_control behaviour
|
14
|
+
i.e example_color_transform.rb
|
15
|
+
* should be relatively stable now!
|
16
|
+
|
17
|
+
28/8/09
|
18
|
+
version 0.1.9.1 (still BETA)
|
19
|
+
* experimental features: Gosu::Image#dup and Gosu::Image#clone
|
20
|
+
* also TexPlay::create_blank_image(window, width, height)
|
21
|
+
* I noticed these features SEG FAULT on my setup in windows, so be warned
|
22
|
+
* This is a BETA release
|
23
|
+
|
24
|
+
14/8/09
|
25
|
+
version 0.1.9.0 (BETA)
|
26
|
+
* major rewrite. TP now supports beziers, polylines, polygons, and more
|
27
|
+
* also supports alpha_blending (though still tempermental)
|
28
|
+
* This is a BETA release
|
29
|
+
|
30
|
+
1/7/09
|
31
|
+
version 0.1.6.2
|
32
|
+
* fixed another subtle bug in constrain_local_boundaries(). Function was
|
33
|
+
unable to deal with drawing actions that were 100% outside the image
|
34
|
+
boundaries.
|
35
|
+
|
36
|
+
28/6/09
|
37
|
+
version 0.1.6
|
38
|
+
* gen_eval now working as a replacement for instance_eval in the #paint block. Allows for more user-friendly interface.
|
39
|
+
* #paint can now be called without a block; if invoked this way it executes any commands in the action queue, e.g
|
40
|
+
@img.circle 20, 20, 40
|
41
|
+
@img.pixel 30, 30
|
42
|
+
@img.paint
|
43
|
+
* above will function as if: @img.paint { circle 20, 20, 40; pixel 30, 30 }
|
44
|
+
* collected 1.8.6/1.9.1 compatibility into compat.h
|
45
|
+
|
46
|
+
16/6/09
|
47
|
+
version 0.1.4.6
|
48
|
+
* allowed arity of 0 (as well as -1) for ruby 1.9 compatibility
|
49
|
+
|
50
|
+
13/6/09
|
51
|
+
version 0.1.4.5
|
52
|
+
* major bugfix with TexPlay#splice method (segfaut). Also added new color format parameter: color [1, 1, 0, 1] (e.g purple with full alpha).
|
53
|
+
Also fixed subtle edge-case bug in constrain_local_boundaries().
|
54
|
+
|
55
|
+
9/6/09
|
56
|
+
version 0.1.4
|
57
|
+
* improved error checking. should work better with later gosu releases
|
58
|
+
|
59
|
+
20/2/09
|
60
|
+
version 0.1.1
|
61
|
+
* rerelease of this version fixing the oversized image bug for refresh_cache (i.e images over 500 x 500
|
62
|
+
|
63
|
+
version 0.1.1
|
64
|
+
* oops, bug in leftshift/rightshift functions, fixed!
|
65
|
+
|
66
|
+
version 0.1.0
|
67
|
+
* release!
|
68
|
+
|
data/README
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
INSTRUCTIONS
|
2
|
+
|
3
|
+
TexPlay version 0.2.1
|
4
|
+
|
5
|
+
To compile TexPlay, ensure you are in the directory with the Rakefile and type:
|
6
|
+
=> rake
|
7
|
+
OR
|
8
|
+
=> rake19 (assuming this is the name of your 1.9.1 version of rake)
|
9
|
+
|
10
|
+
!!NB!! be sure to run the version of rake that corresponds to the ruby version you wish to use! on my system I use rake19 for ruby 1.9.1!!
|
11
|
+
|
12
|
+
If all goes well, run the example programs:
|
13
|
+
=> cd examples
|
14
|
+
=> ruby example_melt.rb
|
15
|
+
=> ruby example_simple.rb
|
16
|
+
=> ..etc
|
17
|
+
|
18
|
+
*like any gosu application, gosu.so must be in the current directory (or the gosu gem installed) when running the examples.
|
19
|
+
|
20
|
+
Enjoy!
|
21
|
+
(note that TexPlay has only been tested on 32 bit linux systems and WindowsXP using VS 6.0)
|
data/README1st
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
INSTRUCTIONS
|
2
|
+
|
3
|
+
TexPlay version 0.2.1
|
4
|
+
|
5
|
+
*Ensure that ctexplay.so and gosu.so, and texplay.rb and texplay-contrib.rb are in the working directory for your project
|
6
|
+
*require 'texplay' in your ruby program to access the TexPlay module
|
7
|
+
*see example programs, for illustration of use
|
8
|
+
|
9
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,85 @@
|
|
1
|
+
require 'rake/clean'
|
2
|
+
require 'rake/gempackagetask'
|
3
|
+
|
4
|
+
$dlext = Config::CONFIG['DLEXT']
|
5
|
+
|
6
|
+
CLEAN.include("src/*.#{$dlext}", "src/*.log", "src/*.o", "src/*~", "src/*#*", "src/*.obj", "src/*.def", "src/*.pdb")
|
7
|
+
CLOBBER.include("**/*.#{$dlext}", "**/*~", "**/*#*", "**/*.log", "**/*.o")
|
8
|
+
|
9
|
+
$make_program = if RUBY_PLATFORM =~ /win/
|
10
|
+
"nmake"
|
11
|
+
else
|
12
|
+
"make"
|
13
|
+
end
|
14
|
+
|
15
|
+
task :default => [:build]
|
16
|
+
|
17
|
+
desc "Build TexPlay"
|
18
|
+
task :build => :clean do
|
19
|
+
puts "(2) building Makefile..."
|
20
|
+
chdir("./src/") do
|
21
|
+
ruby "extconf.rb"
|
22
|
+
puts "(3) building ctexplay.#{$dlext}..."
|
23
|
+
sh "#{$make_program}"
|
24
|
+
puts "(4) copying ctexplay.#{$dlext} to current directory..."
|
25
|
+
cp "ctexplay.#{$dlext}", "../lib" , :verbose => true
|
26
|
+
|
27
|
+
if RUBY_PLATFORM =~ /mswin/
|
28
|
+
if RUBY_VERSION =~ /1.9/
|
29
|
+
File.rename("../lib/ctexplay.#{$dlext}", "../lib/ctexplay.19.#{$dlext}")
|
30
|
+
else
|
31
|
+
File.rename("../lib/ctexplay.#{$dlext}", "../lib/ctexplay.18.#{$dlext}")
|
32
|
+
end
|
33
|
+
end
|
34
|
+
puts "(5) ...done!"
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
specification = Gem::Specification.new do |s|
|
39
|
+
s.name = "texplay"
|
40
|
+
s.summary = "TexPlay is a light-weight image manipulation framework for Ruby and Gosu"
|
41
|
+
s.version = "0.2.1"
|
42
|
+
s.date = "2009-09-02"
|
43
|
+
s.author = "John Mair (banisterfiend)"
|
44
|
+
s.email = 'jrmair@gmail.com'
|
45
|
+
s.description = s.summary
|
46
|
+
s.require_path = 'lib'
|
47
|
+
s.add_dependency("gosu",">=0.7.14")
|
48
|
+
s.homepage = "http://banisterfiend.wordpress.com/2008/08/23/texplay-an-image-manipulation-tool-for-ruby-and-gosu/"
|
49
|
+
s.has_rdoc = false
|
50
|
+
s.files = ["Rakefile", "README", "CHANGELOG", "README1st",
|
51
|
+
"lib/texplay.rb", "lib/texplay-contrib.rb"] +
|
52
|
+
FileList["src/*", "examples/*.rb", "examples/media/*"].to_a
|
53
|
+
|
54
|
+
if RUBY_PLATFORM =~ /mswin/
|
55
|
+
s.platform = Gem::Platform::CURRENT
|
56
|
+
s.files += ["lib/ctexplay.18.so", "lib/ctexplay.19.so"]
|
57
|
+
|
58
|
+
else
|
59
|
+
s.platform = Gem::Platform::RUBY
|
60
|
+
s.extensions = ["src/extconf.rb"]
|
61
|
+
end
|
62
|
+
end
|
63
|
+
Rake::GemPackageTask.new(specification) do |package|
|
64
|
+
package.need_zip = false
|
65
|
+
package.need_tar = false
|
66
|
+
end
|
67
|
+
|
68
|
+
SELENE = '/home/john/ruby/projects/selene'
|
69
|
+
desc "update selene's version of texplay"
|
70
|
+
task :selene => ["#{SELENE}/lib/texplay.rb", "#{SELENE}/lib/texplay-contrib.rb",
|
71
|
+
"#{SELENE}/lib/ctexplay.so"] do
|
72
|
+
puts "...done!"
|
73
|
+
end
|
74
|
+
|
75
|
+
file "#{SELENE}/lib/texplay.rb" => "texplay.rb" do |t|
|
76
|
+
cp t.prerequisites.first, t.name, :verbose => true
|
77
|
+
end
|
78
|
+
|
79
|
+
file "#{SELENE}/lib/texplay-contrib.rb" => "texplay-contrib.rb" do |t|
|
80
|
+
cp t.prerequisites.first, t.name, :verbose => true
|
81
|
+
end
|
82
|
+
|
83
|
+
file "#{SELENE}/lib/ctexplay.#{$dlext}" => "ctexplay.#{$dlext}" do |t|
|
84
|
+
cp t.prerequisites.first, t.name, :verbose => true
|
85
|
+
end
|
data/examples/basic.rb
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
|
2
|
+
require 'rubygems'
|
3
|
+
require 'common'
|
4
|
+
|
5
|
+
require 'gosu'
|
6
|
+
require 'texplay'
|
7
|
+
|
8
|
+
class W < Gosu::Window
|
9
|
+
def initialize
|
10
|
+
super(1024, 769, false, 20)
|
11
|
+
@img = Gosu::Image.new(self, "#{Common::MEDIA}/sunset.png")
|
12
|
+
@img.rect 0,0, @img.width - 1, @img.height - 1
|
13
|
+
|
14
|
+
@img.instance_variable_set(:@horse, :love)
|
15
|
+
class << @img
|
16
|
+
def little
|
17
|
+
:little
|
18
|
+
end
|
19
|
+
end
|
20
|
+
@bunk = @img.clone
|
21
|
+
puts @bunk.instance_variable_get(:@horse)
|
22
|
+
puts @bunk.little
|
23
|
+
end
|
24
|
+
|
25
|
+
def draw
|
26
|
+
x = @img.width * rand
|
27
|
+
y = @img.height * rand
|
28
|
+
|
29
|
+
@img.
|
30
|
+
line(0, 0, 1024, 1024).
|
31
|
+
circle(20, 20, 50).
|
32
|
+
rect 30, 30, 100, 100
|
33
|
+
|
34
|
+
@img.draw 100, 50,1
|
35
|
+
@bunk.draw 500, 300,1
|
36
|
+
@bunk.line 0, 0, 1024, 1024, :color => :red
|
37
|
+
|
38
|
+
|
39
|
+
|
40
|
+
@bunk.pixel x, y, :color => :none
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
|
45
|
+
|
46
|
+
w = W.new
|
47
|
+
w.show
|
48
|
+
|
data/examples/basic2.rb
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'common'
|
3
|
+
require 'gosu'
|
4
|
+
require 'texplay'
|
5
|
+
|
6
|
+
class Proc
|
7
|
+
def __context__
|
8
|
+
eval('self', self.binding)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
class W < Gosu::Window
|
13
|
+
def initialize
|
14
|
+
super(1024, 769, false, 20)
|
15
|
+
@img = Gosu::Image.new(self, "#{Common::MEDIA}/texplay.png")
|
16
|
+
end
|
17
|
+
|
18
|
+
def trick
|
19
|
+
@img.dup_eval { self }
|
20
|
+
end
|
21
|
+
|
22
|
+
def draw
|
23
|
+
@img.paint {
|
24
|
+
circle -5100, -9700, 20
|
25
|
+
circle(@img.width * rand * 2 - @img.width, @img.height * rand * 2 - @img.height, 40)
|
26
|
+
}
|
27
|
+
@img.draw(100,100,1)
|
28
|
+
end
|
29
|
+
|
30
|
+
def img
|
31
|
+
@img
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
w = W.new
|
36
|
+
w.show
|
37
|
+
|
@@ -0,0 +1,299 @@
|
|
1
|
+
# TexPlay test program
|
2
|
+
|
3
|
+
begin
|
4
|
+
require 'rubygems'
|
5
|
+
rescue LoadError
|
6
|
+
|
7
|
+
end
|
8
|
+
|
9
|
+
require 'common'
|
10
|
+
require 'gosu'
|
11
|
+
require 'texplay'
|
12
|
+
require 'benchmark'
|
13
|
+
|
14
|
+
class MyWindow < Gosu::Window
|
15
|
+
|
16
|
+
# set to true for visible output
|
17
|
+
# note, benchmarks will not happen until
|
18
|
+
# viewing window is closed
|
19
|
+
SHOW = false
|
20
|
+
|
21
|
+
def initialize
|
22
|
+
super(1024, 768, false, 20)
|
23
|
+
@img = Gosu::Image.new(self,"#{Common::MEDIA}/texplay.png")
|
24
|
+
@img2 = Gosu::Image.new(self,"#{Common::MEDIA}/texplay.png")
|
25
|
+
@gosu = Gosu::Image.new(self, "#{Common::MEDIA}/gosu.png")
|
26
|
+
@empty1 = Gosu::Image.new(self, "#{Common::MEDIA}/empty2.png")
|
27
|
+
@empty2 = Gosu::Image.new(self, "#{Common::MEDIA}/empty2.png")
|
28
|
+
@empty3 = Gosu::Image.new(self, "#{Common::MEDIA}/empty2.png")
|
29
|
+
@width = @img.width
|
30
|
+
@height = @img.height
|
31
|
+
|
32
|
+
# default number of iterations
|
33
|
+
@repeat = 1000
|
34
|
+
|
35
|
+
if ARGV.first.to_i != 0 then
|
36
|
+
@repeat = ARGV.shift.to_i
|
37
|
+
end
|
38
|
+
|
39
|
+
if SHOW then
|
40
|
+
class << self
|
41
|
+
alias_method :draw, :_draw
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def bench_all
|
47
|
+
x1 = rand @width
|
48
|
+
y1 = rand @height
|
49
|
+
x2 = rand @width
|
50
|
+
y2 = rand @height
|
51
|
+
|
52
|
+
@img.paint {
|
53
|
+
color :random
|
54
|
+
circle x1, y1, 10
|
55
|
+
line x1, y1, x2, y2
|
56
|
+
rect x1, y1, x2 + 100, y2 + 100
|
57
|
+
pixel x1, y1
|
58
|
+
}
|
59
|
+
end
|
60
|
+
|
61
|
+
def bench_clear
|
62
|
+
@img.paint {
|
63
|
+
clear
|
64
|
+
}
|
65
|
+
end
|
66
|
+
|
67
|
+
def bench_circle
|
68
|
+
x = rand @width
|
69
|
+
y = rand @height
|
70
|
+
r = 50
|
71
|
+
|
72
|
+
@img.circle x, y, r
|
73
|
+
|
74
|
+
end
|
75
|
+
|
76
|
+
def bench_pixel
|
77
|
+
@img.paint {
|
78
|
+
color :random
|
79
|
+
pixel (@img.width * rand), (@img.width * rand)
|
80
|
+
}
|
81
|
+
end
|
82
|
+
|
83
|
+
def bench_splice
|
84
|
+
@img.paint {
|
85
|
+
splice(@img2, (@img.width * rand), (@img.height * rand))
|
86
|
+
}
|
87
|
+
end
|
88
|
+
|
89
|
+
|
90
|
+
def bench_splice_same
|
91
|
+
@img.paint {
|
92
|
+
splice(@img, (@img.width * rand), (@img.height * rand))
|
93
|
+
}
|
94
|
+
end
|
95
|
+
|
96
|
+
def bench_special_pixel
|
97
|
+
@img.paint {
|
98
|
+
self[(@img.width * rand), (@img.height * rand)] = :random
|
99
|
+
}
|
100
|
+
end
|
101
|
+
|
102
|
+
def bench_line
|
103
|
+
x1 = rand @width
|
104
|
+
y1 = rand @height
|
105
|
+
x2 = rand @width
|
106
|
+
y2 = rand @height
|
107
|
+
|
108
|
+
|
109
|
+
@img.line x1, y1, x2, y2
|
110
|
+
|
111
|
+
end
|
112
|
+
|
113
|
+
def bench_pline
|
114
|
+
x1 = rand @width
|
115
|
+
y1 = rand @height
|
116
|
+
x2 = rand @width
|
117
|
+
y2 = rand @height
|
118
|
+
|
119
|
+
|
120
|
+
@img.paint {
|
121
|
+
line x1, y1, x2, y2
|
122
|
+
}
|
123
|
+
|
124
|
+
end
|
125
|
+
|
126
|
+
def bench_box
|
127
|
+
x1 = rand @width
|
128
|
+
y1 = rand @height
|
129
|
+
x2 = rand @width
|
130
|
+
y2 = rand @height
|
131
|
+
|
132
|
+
@img.paint {
|
133
|
+
rect rand(@width),rand(@width),rand(@width),rand(@width)
|
134
|
+
}
|
135
|
+
end
|
136
|
+
|
137
|
+
def bench_anti_each
|
138
|
+
0.upto(@img.width - 1) { |x|
|
139
|
+
0.upto(@img.height - 1) { |y|
|
140
|
+
clr = @img.get_pixel(x, y)
|
141
|
+
|
142
|
+
clr[0] += 1
|
143
|
+
|
144
|
+
@img.color clr
|
145
|
+
@img.pixel(x, y)
|
146
|
+
}
|
147
|
+
}
|
148
|
+
end
|
149
|
+
|
150
|
+
def bench_each
|
151
|
+
@img.each { |v| v[0] = 1}
|
152
|
+
end
|
153
|
+
|
154
|
+
def bench_each2
|
155
|
+
@img.each2 { |v| v[0] = 1}
|
156
|
+
end
|
157
|
+
|
158
|
+
def bench_image_new
|
159
|
+
Gosu::Image.new(self, "#{Common::MEDIA}/empty2.png")
|
160
|
+
end
|
161
|
+
|
162
|
+
def bench_create_blank
|
163
|
+
truck = TexPlay::create_blank_image(self, @img.width, @img.height)
|
164
|
+
truck.splice(@img, 0, 0)
|
165
|
+
|
166
|
+
end
|
167
|
+
|
168
|
+
def bench_dup
|
169
|
+
@img.dup
|
170
|
+
end
|
171
|
+
|
172
|
+
def bench_clone
|
173
|
+
@img.clone
|
174
|
+
end
|
175
|
+
|
176
|
+
def bench_composite
|
177
|
+
@img.splice @img2, 0, 0
|
178
|
+
end
|
179
|
+
|
180
|
+
def bench_rect
|
181
|
+
@img.rect 0, 0, 1024, 1024, :fill => true
|
182
|
+
end
|
183
|
+
|
184
|
+
def bench_gen_eval
|
185
|
+
@img.paint {
|
186
|
+
0.upto(1000) {
|
187
|
+
circle 100,100, 10
|
188
|
+
}
|
189
|
+
}
|
190
|
+
end
|
191
|
+
|
192
|
+
def bench_eager_sync
|
193
|
+
@img.paint(:lazy_sync => false) {
|
194
|
+
# 1.upto(1000) {
|
195
|
+
# color :blue
|
196
|
+
### circle (10), (10), 10
|
197
|
+
clear
|
198
|
+
#circle (@img.width * rand), (@img.height * rand), 10
|
199
|
+
# }
|
200
|
+
}
|
201
|
+
end
|
202
|
+
|
203
|
+
def bench_lazy_sync
|
204
|
+
@img.paint(:lazy_sync => true) {
|
205
|
+
# 1.upto(1000) {
|
206
|
+
# color :blue
|
207
|
+
# circle (10), (10), 10
|
208
|
+
clear
|
209
|
+
#circle (@img.width * rand), (@img.height * rand), 10
|
210
|
+
# }
|
211
|
+
|
212
|
+
}
|
213
|
+
end
|
214
|
+
|
215
|
+
|
216
|
+
def bench_yield
|
217
|
+
@img.paint { |c|
|
218
|
+
0.upto(1000) {
|
219
|
+
c.circle 100,100, 10
|
220
|
+
}
|
221
|
+
}
|
222
|
+
end
|
223
|
+
|
224
|
+
def bench_instance_eval
|
225
|
+
@img.instance_eval {
|
226
|
+
0.upto(1000) {
|
227
|
+
circle 100,100, 10
|
228
|
+
}
|
229
|
+
}
|
230
|
+
end
|
231
|
+
|
232
|
+
def bench_glow_fill
|
233
|
+
@empty2.fill 100,100
|
234
|
+
end
|
235
|
+
|
236
|
+
def bench_scan_fill_style
|
237
|
+
@empty2.fill 100,100, :scan => true, :style => true, :color => :random
|
238
|
+
end
|
239
|
+
|
240
|
+
def bench_scan_fill
|
241
|
+
@empty3.fill 100,100, :scan => true, :color => :random
|
242
|
+
end
|
243
|
+
|
244
|
+
def bench_iter_fill
|
245
|
+
@empty3.fill 100,100, :iter => true
|
246
|
+
end
|
247
|
+
|
248
|
+
def bench_polyline_thick
|
249
|
+
@empty2.polyline [100, 200, 0, 0, 150, 500, 500, 0], :closed => true, :texture => @tp, :thickness => 2,
|
250
|
+
:alpha_blend => true, :sync_mode => :no_sync
|
251
|
+
end
|
252
|
+
|
253
|
+
def bench_polyline
|
254
|
+
ps = []
|
255
|
+
13.times {
|
256
|
+
p = [@empty2.width * rand, @empty2.height * rand]
|
257
|
+
ps += p
|
258
|
+
}
|
259
|
+
# ps = [110, 110, 210, 210]
|
260
|
+
@empty2.polyline ps
|
261
|
+
end
|
262
|
+
|
263
|
+
def bench_bezier
|
264
|
+
ps = []
|
265
|
+
13.times {
|
266
|
+
p = [@empty2.width * rand, @empty2.height * rand]
|
267
|
+
ps += p
|
268
|
+
}
|
269
|
+
@empty2.bezier ps
|
270
|
+
end
|
271
|
+
|
272
|
+
def _draw
|
273
|
+
@img.draw(200, 200, 0)
|
274
|
+
end
|
275
|
+
|
276
|
+
def do_benchmarks
|
277
|
+
puts "performing #{@repeat} iterations..."
|
278
|
+
|
279
|
+
bench_meths = ARGV
|
280
|
+
|
281
|
+
if ARGV.empty? then
|
282
|
+
bench_meths = self.methods.select { |x| x =~ /bench/ }.map { |x| x.to_s.sub("bench_", "") }
|
283
|
+
end
|
284
|
+
|
285
|
+
Benchmark.bmbm do |v|
|
286
|
+
bench_meths.each { |meth|
|
287
|
+
v.report(meth) { @repeat.times { self.send("bench_#{meth}") } }
|
288
|
+
}
|
289
|
+
end
|
290
|
+
end
|
291
|
+
end
|
292
|
+
|
293
|
+
w = MyWindow.new
|
294
|
+
|
295
|
+
if MyWindow::SHOW
|
296
|
+
w.show
|
297
|
+
end
|
298
|
+
|
299
|
+
w.do_benchmarks
|