texplay 0.2.2-x86-mswin32-60 → 0.2.4-x86-mswin32-60

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/CHANGELOG CHANGED
@@ -1,78 +1,88 @@
1
- 8/9/09
2
- version 0.2.2
3
- * fixed color_control bug, action_struct->color was being overwritten (now using a temp).
4
- * fixed faulty error msg where max tex size was being displayed as 1024 but is actually 1022
5
- * added :start_angle parameter to ngon action
6
- * fixed example screen height from 769 to 768
7
- * arity of -1 and 0 now supported for color_control procs
8
- * fixed parameter checks for circle and ngon
9
- * updated documentation to reflect changes, and added details on caching
10
-
11
- 2/9/09
12
- version 0.2.1
13
- * releasing a gem for TexPlay
14
- * bumped version number so can add add gosu 0.7.14 dependency to github gem
15
- * hopefully gem works on both github and rubyforge
16
- 31/8/09
17
- version 0.2.0
18
- * added each iterator
19
- * added alternative to proc for :color_control proc (allowing static linear transforms to pixels)
20
- * no longer segfaulting on windows (no idea why not)
21
- * rewrote EmptyImageStub in ruby, using philomory's code. now alot faster.
22
- * implemented 'shadow' in terms of static :color_control pixel transform
23
- * added more example code demonstrating each iterator (example_each.rb) and new color_control behaviour
24
- i.e example_color_transform.rb
25
- * should be relatively stable now!
26
-
27
- 28/8/09
28
- version 0.1.9.1 (still BETA)
29
- * experimental features: Gosu::Image#dup and Gosu::Image#clone
30
- * also TexPlay::create_blank_image(window, width, height)
31
- * I noticed these features SEG FAULT on my setup in windows, so be warned
32
- * This is a BETA release
33
-
34
- 14/8/09
35
- version 0.1.9.0 (BETA)
36
- * major rewrite. TP now supports beziers, polylines, polygons, and more
37
- * also supports alpha_blending (though still tempermental)
38
- * This is a BETA release
39
-
40
- 1/7/09
41
- version 0.1.6.2
42
- * fixed another subtle bug in constrain_local_boundaries(). Function was
43
- unable to deal with drawing actions that were 100% outside the image
44
- boundaries.
45
-
46
- 28/6/09
47
- version 0.1.6
48
- * gen_eval now working as a replacement for instance_eval in the #paint block. Allows for more user-friendly interface.
49
- * #paint can now be called without a block; if invoked this way it executes any commands in the action queue, e.g
50
- @img.circle 20, 20, 40
51
- @img.pixel 30, 30
52
- @img.paint
53
- * above will function as if: @img.paint { circle 20, 20, 40; pixel 30, 30 }
54
- * collected 1.8.6/1.9.1 compatibility into compat.h
55
-
56
- 16/6/09
57
- version 0.1.4.6
58
- * allowed arity of 0 (as well as -1) for ruby 1.9 compatibility
59
-
60
- 13/6/09
61
- version 0.1.4.5
62
- * major bugfix with TexPlay#splice method (segfaut). Also added new color format parameter: color [1, 1, 0, 1] (e.g purple with full alpha).
63
- Also fixed subtle edge-case bug in constrain_local_boundaries().
64
-
65
- 9/6/09
66
- version 0.1.4
67
- * improved error checking. should work better with later gosu releases
68
-
69
- 20/2/09
70
- version 0.1.1
71
- * rerelease of this version fixing the oversized image bug for refresh_cache (i.e images over 500 x 500
72
-
73
- version 0.1.1
74
- * oops, bug in leftshift/rightshift functions, fixed!
75
-
76
- version 0.1.0
77
- * release!
78
-
1
+ 15/9/09
2
+ version 0.2.4
3
+ * added lsystem
4
+ * made lsystem both 1.9.1 and 1.8.6 compatible
5
+
6
+ 11/9/09
7
+ version 0.2.3
8
+ * added Ruby 1.8.7 compatibility by modifying extconf.rb to define RUBY_19 macro
9
+ * and modified compat.h to get rid of feature test (fails on 1.8.7)
10
+
11
+ 8/9/09
12
+ version 0.2.2
13
+ * fixed color_control bug, action_struct->color was being overwritten (now using a temp).
14
+ * fixed faulty error msg where max tex size was being displayed as 1024 but is actually 1022
15
+ * added :start_angle parameter to ngon action
16
+ * fixed example screen height from 769 to 768
17
+ * arity of -1 and 0 now supported for color_control procs
18
+ * fixed parameter checks for circle and ngon
19
+ * updated documentation to reflect changes, and added details on caching
20
+
21
+ 2/9/09
22
+ version 0.2.1
23
+ * releasing a gem for TexPlay
24
+ * bumped version number so can add add gosu 0.7.14 dependency to github gem
25
+ * hopefully gem works on both github and rubyforge
26
+ 31/8/09
27
+ version 0.2.0
28
+ * added each iterator
29
+ * added alternative to proc for :color_control proc (allowing static linear transforms to pixels)
30
+ * no longer segfaulting on windows (no idea why not)
31
+ * rewrote EmptyImageStub in ruby, using philomory's code. now alot faster.
32
+ * implemented 'shadow' in terms of static :color_control pixel transform
33
+ * added more example code demonstrating each iterator (example_each.rb) and new color_control behaviour
34
+ i.e example_color_transform.rb
35
+ * should be relatively stable now!
36
+
37
+ 28/8/09
38
+ version 0.1.9.1 (still BETA)
39
+ * experimental features: Gosu::Image#dup and Gosu::Image#clone
40
+ * also TexPlay::create_blank_image(window, width, height)
41
+ * I noticed these features SEG FAULT on my setup in windows, so be warned
42
+ * This is a BETA release
43
+
44
+ 14/8/09
45
+ version 0.1.9.0 (BETA)
46
+ * major rewrite. TP now supports beziers, polylines, polygons, and more
47
+ * also supports alpha_blending (though still tempermental)
48
+ * This is a BETA release
49
+
50
+ 1/7/09
51
+ version 0.1.6.2
52
+ * fixed another subtle bug in constrain_local_boundaries(). Function was
53
+ unable to deal with drawing actions that were 100% outside the image
54
+ boundaries.
55
+
56
+ 28/6/09
57
+ version 0.1.6
58
+ * gen_eval now working as a replacement for instance_eval in the #paint block. Allows for more user-friendly interface.
59
+ * #paint can now be called without a block; if invoked this way it executes any commands in the action queue, e.g
60
+ @img.circle 20, 20, 40
61
+ @img.pixel 30, 30
62
+ @img.paint
63
+ * above will function as if: @img.paint { circle 20, 20, 40; pixel 30, 30 }
64
+ * collected 1.8.6/1.9.1 compatibility into compat.h
65
+
66
+ 16/6/09
67
+ version 0.1.4.6
68
+ * allowed arity of 0 (as well as -1) for ruby 1.9 compatibility
69
+
70
+ 13/6/09
71
+ version 0.1.4.5
72
+ * major bugfix with TexPlay#splice method (segfaut). Also added new color format parameter: color [1, 1, 0, 1] (e.g purple with full alpha).
73
+ Also fixed subtle edge-case bug in constrain_local_boundaries().
74
+
75
+ 9/6/09
76
+ version 0.1.4
77
+ * improved error checking. should work better with later gosu releases
78
+
79
+ 20/2/09
80
+ version 0.1.1
81
+ * rerelease of this version fixing the oversized image bug for refresh_cache (i.e images over 500 x 500
82
+
83
+ version 0.1.1
84
+ * oops, bug in leftshift/rightshift functions, fixed!
85
+
86
+ version 0.1.0
87
+ * release!
88
+
data/README.markdown CHANGED
@@ -1,35 +1,35 @@
1
- ![Alt text](https://dl.getdropbox.com/u/239375/texplay.png)
2
-
3
- *an image manipulation tool for ruby and gosu*
4
-
5
- INSTRUCTIONS
6
- ============
7
-
8
- **TexPlay version 0.2.2**
9
-
10
- Gem installation:
11
-
12
- + sudo gem install texplay
13
-
14
- To compile TexPlay from source, ensure you are in the directory with the Rakefile and type:
15
-
16
- + rake
17
-
18
- OR
19
-
20
- + rake19 (assuming this is the name of your 1.9.1 version of rake)
21
-
22
- **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!
23
-
24
- If all goes well, run the example programs:
25
-
26
- + cd examples
27
- + ruby example_melt.rb
28
- + ruby example_simple.rb
29
- + ..etc
30
-
31
- + like any gosu application, gosu.so must be in the current directory (or the gosu gem installed) when running the examples.
32
-
33
-
34
- ---
35
- Enjoy!
1
+ ![Alt text](https://dl.getdropbox.com/u/239375/texplay.png)
2
+
3
+ *an image manipulation tool for ruby and gosu*
4
+
5
+ INSTRUCTIONS
6
+ ============
7
+
8
+ **TexPlay version 0.2.4**
9
+
10
+ Gem installation:
11
+
12
+ + sudo gem install texplay
13
+
14
+ To compile TexPlay from source, ensure you are in the directory with the Rakefile and type:
15
+
16
+ + rake
17
+
18
+ OR
19
+
20
+ + rake19 (assuming this is the name of your 1.9.1 version of rake)
21
+
22
+ **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!
23
+
24
+ If all goes well, run the example programs:
25
+
26
+ + cd examples
27
+ + ruby example_melt.rb
28
+ + ruby example_simple.rb
29
+ + ..etc
30
+
31
+ + like any gosu application, gosu.so must be in the current directory (or the gosu gem installed) when running the examples.
32
+
33
+
34
+ ---
35
+ Enjoy!
data/Rakefile CHANGED
@@ -1,87 +1,87 @@
1
- require 'rake/clean'
2
- require 'rake/gempackagetask'
3
-
4
- TEXPLAY_VERSION = "0.2.2"
5
-
6
- $dlext = Config::CONFIG['DLEXT']
7
-
8
- CLEAN.include("src/*.#{$dlext}", "src/*.log", "src/*.o", "src/*~", "src/*#*", "src/*.obj", "src/*.def", "src/*.pdb")
9
- CLOBBER.include("**/*.#{$dlext}", "**/*~", "**/*#*", "**/*.log", "**/*.o")
10
-
11
- $make_program = if RUBY_PLATFORM =~ /win/
12
- "nmake"
13
- else
14
- "make"
15
- end
16
-
17
- task :default => [:build]
18
-
19
- desc "Build TexPlay"
20
- task :build => :clean do
21
- puts "(2) building Makefile..."
22
- chdir("./src/") do
23
- ruby "extconf.rb"
24
- puts "(3) building ctexplay.#{$dlext}..."
25
- sh "#{$make_program}"
26
- puts "(4) copying ctexplay.#{$dlext} to current directory..."
27
- cp "ctexplay.#{$dlext}", "../lib" , :verbose => true
28
-
29
- if RUBY_PLATFORM =~ /mswin/
30
- if RUBY_VERSION =~ /1.9/
31
- File.rename("../lib/ctexplay.#{$dlext}", "../lib/ctexplay.19.#{$dlext}")
32
- else
33
- File.rename("../lib/ctexplay.#{$dlext}", "../lib/ctexplay.18.#{$dlext}")
34
- end
35
- end
36
- puts "(5) ...done!"
37
- end
38
- end
39
-
40
- specification = Gem::Specification.new do |s|
41
- s.name = "texplay"
42
- s.summary = "TexPlay is a light-weight image manipulation framework for Ruby and Gosu"
43
- s.version = TEXPLAY_VERSION
44
- s.date = "2009-09-09"
45
- s.author = "John Mair (banisterfiend)"
46
- s.email = 'jrmair@gmail.com'
47
- s.description = s.summary
48
- s.require_path = 'lib'
49
- s.add_dependency("gosu",">=0.7.14")
50
- s.homepage = "http://banisterfiend.wordpress.com/2008/08/23/texplay-an-image-manipulation-tool-for-ruby-and-gosu/"
51
- s.has_rdoc = false
52
- s.files = ["Rakefile", "README.markdown", "CHANGELOG", "README1st",
53
- "lib/texplay.rb", "lib/texplay-contrib.rb"] +
54
- FileList["src/*", "examples/*.rb", "examples/media/*"].to_a
55
-
56
- if RUBY_PLATFORM =~ /mswin/
57
- s.platform = Gem::Platform::CURRENT
58
- s.files += ["lib/ctexplay.18.so", "lib/ctexplay.19.so"]
59
-
60
- else
61
- s.platform = Gem::Platform::RUBY
62
- s.extensions = ["src/extconf.rb"]
63
- end
64
- end
65
- Rake::GemPackageTask.new(specification) do |package|
66
- package.need_zip = false
67
- package.need_tar = false
68
- end
69
-
70
- SELENE = '/home/john/ruby/projects/selene'
71
- desc "update selene's version of texplay"
72
- task :selene => ["#{SELENE}/lib/texplay.rb", "#{SELENE}/lib/texplay-contrib.rb",
73
- "#{SELENE}/lib/ctexplay.so"] do
74
- puts "...done!"
75
- end
76
-
77
- file "#{SELENE}/lib/texplay.rb" => "texplay.rb" do |t|
78
- cp t.prerequisites.first, t.name, :verbose => true
79
- end
80
-
81
- file "#{SELENE}/lib/texplay-contrib.rb" => "texplay-contrib.rb" do |t|
82
- cp t.prerequisites.first, t.name, :verbose => true
83
- end
84
-
85
- file "#{SELENE}/lib/ctexplay.#{$dlext}" => "ctexplay.#{$dlext}" do |t|
86
- cp t.prerequisites.first, t.name, :verbose => true
87
- end
1
+ require 'rake/clean'
2
+ require 'rake/gempackagetask'
3
+
4
+ TEXPLAY_VERSION = "0.2.4"
5
+
6
+ $dlext = Config::CONFIG['DLEXT']
7
+
8
+ CLEAN.include("src/*.#{$dlext}", "src/*.log", "src/*.o", "src/*~", "src/*#*", "src/*.obj", "src/*.def", "src/*.pdb")
9
+ CLOBBER.include("**/*.#{$dlext}", "**/*~", "**/*#*", "**/*.log", "**/*.o")
10
+
11
+ $make_program = if RUBY_PLATFORM =~ /win/
12
+ "nmake"
13
+ else
14
+ "make"
15
+ end
16
+
17
+ task :default => [:build]
18
+
19
+ desc "Build TexPlay"
20
+ task :build => :clean do
21
+ puts "(2) building Makefile..."
22
+ chdir("./src/") do
23
+ ruby "extconf.rb"
24
+ puts "(3) building ctexplay.#{$dlext}..."
25
+ sh "#{$make_program}"
26
+ puts "(4) copying ctexplay.#{$dlext} to current directory..."
27
+ cp "ctexplay.#{$dlext}", "../lib" , :verbose => true
28
+
29
+ if RUBY_PLATFORM =~ /mswin/
30
+ if RUBY_VERSION =~ /1.9/
31
+ File.rename("../lib/ctexplay.#{$dlext}", "../lib/ctexplay.19.#{$dlext}")
32
+ else
33
+ File.rename("../lib/ctexplay.#{$dlext}", "../lib/ctexplay.18.#{$dlext}")
34
+ end
35
+ end
36
+ puts "(5) ...done!"
37
+ end
38
+ end
39
+
40
+ specification = Gem::Specification.new do |s|
41
+ s.name = "texplay"
42
+ s.summary = "TexPlay is a light-weight image manipulation framework for Ruby and Gosu"
43
+ s.version = TEXPLAY_VERSION
44
+ s.date = "2009-09-09"
45
+ s.author = "John Mair (banisterfiend)"
46
+ s.email = 'jrmair@gmail.com'
47
+ s.description = s.summary
48
+ s.require_path = 'lib'
49
+ s.add_dependency("gosu",">=0.7.14")
50
+ s.homepage = "http://banisterfiend.wordpress.com/2008/08/23/texplay-an-image-manipulation-tool-for-ruby-and-gosu/"
51
+ s.has_rdoc = false
52
+ s.files = ["Rakefile", "README.markdown", "CHANGELOG",
53
+ "lib/texplay.rb", "lib/texplay-contrib.rb"] +
54
+ FileList["src/*", "examples/*.rb", "examples/media/*"].to_a
55
+
56
+ if RUBY_PLATFORM =~ /mswin/
57
+ s.platform = Gem::Platform::CURRENT
58
+ s.files += ["lib/ctexplay.18.so", "lib/ctexplay.19.so"]
59
+
60
+ else
61
+ s.platform = Gem::Platform::RUBY
62
+ s.extensions = ["src/extconf.rb"]
63
+ end
64
+ end
65
+ Rake::GemPackageTask.new(specification) do |package|
66
+ package.need_zip = false
67
+ package.need_tar = false
68
+ end
69
+
70
+ SELENE = '/home/john/ruby/projects/selene'
71
+ desc "update selene's version of texplay"
72
+ task :selene => ["#{SELENE}/lib/texplay.rb", "#{SELENE}/lib/texplay-contrib.rb",
73
+ "#{SELENE}/lib/ctexplay.so"] do
74
+ puts "...done!"
75
+ end
76
+
77
+ file "#{SELENE}/lib/texplay.rb" => "texplay.rb" do |t|
78
+ cp t.prerequisites.first, t.name, :verbose => true
79
+ end
80
+
81
+ file "#{SELENE}/lib/texplay-contrib.rb" => "texplay-contrib.rb" do |t|
82
+ cp t.prerequisites.first, t.name, :verbose => true
83
+ end
84
+
85
+ file "#{SELENE}/lib/ctexplay.#{$dlext}" => "ctexplay.#{$dlext}" do |t|
86
+ cp t.prerequisites.first, t.name, :verbose => true
87
+ end
@@ -6,7 +6,7 @@ require 'texplay'
6
6
  class W < Gosu::Window
7
7
  def initialize
8
8
  super(1024, 768, false, 20)
9
- @img = TexPlay::create_blank_image(self, 1022, 1022)
9
+ @img = TexPlay::create_blank_image(self, 1022, 800)
10
10
  @tp = Gosu::Image.new(self, "#{Common::MEDIA}/texplay.png")
11
11
  @gosu = Gosu::Image.new(self, "#{Common::MEDIA}/sand1.png")
12
12
 
@@ -25,7 +25,7 @@ class W < Gosu::Window
25
25
  @img.bezier points
26
26
 
27
27
  # NOTE: the :texture hash argument works on ALL drawing actions; not just fills
28
- @img.fill 300, 600, :texture => @gosu
28
+ @img.fill 300, 650, :texture => @gosu
29
29
 
30
30
  # let's demonstrate by drawing a circle using the gosu.png texture
31
31
  # NOTE: :texture even works on lines, boxes, polylines, beziers etc.
@@ -0,0 +1,51 @@
1
+ require 'common'
2
+ require 'texplay'
3
+
4
+ Dragon = TexPlay::LSystem.new do
5
+ rule "F" => "F"
6
+ rule "X" => "X+YF+"
7
+ rule "Y" => "-FX-Y"
8
+ angle 90
9
+
10
+ atom "FX"
11
+ end
12
+
13
+ Bush1 = TexPlay::LSystem.new do
14
+ rule "F" => "F[-F]F[+F][F]"
15
+
16
+ angle 20
17
+ atom "F"
18
+ end
19
+
20
+ Bush2 = TexPlay::LSystem.new do
21
+ rule "F" => "FF"
22
+ rule "X" => "F[+X]F[-X]+X"
23
+
24
+ angle 20
25
+ atom "X"
26
+ end
27
+
28
+ Bush3 = TexPlay::LSystem.new do
29
+ rule "F" => "FF"
30
+ rule "X" => "F-[[X]+X]+F[+FX]-X"
31
+
32
+ angle 22.5
33
+ atom "X"
34
+ end
35
+
36
+
37
+
38
+ class W < Gosu::Window
39
+ def initialize
40
+ super(1024, 768, false, 20)
41
+ @img = TexPlay::create_blank_image(self, 500, 500)
42
+ @img.lsystem(0, 250, Bush2, :order => 5, :line_length => 5)
43
+ end
44
+
45
+ def draw
46
+ @img.draw(100,0,1)
47
+ end
48
+ end
49
+
50
+ w = W.new
51
+ w.show
data/lib/ctexplay.18.so CHANGED
Binary file
data/lib/ctexplay.19.so CHANGED
Binary file
@@ -1,77 +1,149 @@
1
- begin
2
- require 'rubygems'
3
- rescue LoadError
4
- end
5
-
6
- require 'texplay'
7
-
8
- # setup will be executed straight after Gosu::Image instantiation
9
- TexPlay::on_setup do
10
- @turtle_pos = TexPlay::TPPoint.new(width / 2, height / 2 )
11
- @turtle_angle = 0
12
- end
13
-
14
- TexPlay::create_macro(:move_to) do |x, y|
15
- capture {
16
- @turtle_pos.x = x
17
- @turtle_pos.y = y
18
- }
19
- end
20
-
21
- TexPlay::create_macro(:move_rel) do |dx, dy|
22
- capture {
23
- @turtle_pos.x += dx
24
- @turtle_pos.y += dy
25
- }
26
- end
27
-
28
- TexPlay::create_macro(:line_to) do |x, y, *other|
29
- capture {
30
- line(@turtle_pos.x, @turtle_pos.y, x, y, *other)
31
-
32
- @turtle_pos.x, @turtle_pos.y = x, y
33
- }
34
- end
35
-
36
- TexPlay::create_macro(:line_rel) do |dx, dy, *other|
37
- capture {
38
- x = @turtle_pos.x + dx
39
- y = @turtle_pos.y + dy
40
-
41
- line(@turtle_pos.x, @turtle_pos.y, x, y, *other)
42
-
43
- @turtle_pos.x, @turtle_pos.y = x, y
44
- }
45
- end
46
-
47
- TexPlay::create_macro(:turn_to) do |a|
48
- capture {
49
- @turtle_angle = a
50
- }
51
- end
52
-
53
- TexPlay::create_macro(:turn) do |da|
54
- capture {
55
- @turtle_angle += da
56
- }
57
- end
58
-
59
- TexPlay::create_macro(:forward) do |dist, *other|
60
- capture {
61
- visible = other.shift
62
-
63
- radians_per_degree = 0.0174532925199433
64
-
65
- x = @turtle_pos.x + dist * Math::cos(radians_per_degree * @turtle_angle)
66
- y = @turtle_pos.y + dist * Math::sin(radians_per_degree * @turtle_angle)
67
-
68
- if(visible) then
69
- line_to(x, y, *other)
70
- else
71
- move_to(x, y)
72
- end
73
- }
74
- end
75
-
76
-
77
-
1
+ begin
2
+ require 'rubygems'
3
+ rescue LoadError
4
+ end
5
+
6
+ require 'texplay'
7
+
8
+ if RUBY_VERSION =~ /1.8/
9
+ require 'jcode'
10
+ end
11
+
12
+ # setup will be executed straight after Gosu::Image instantiation
13
+ TexPlay::on_setup do
14
+ @turtle_pos = TexPlay::TPPoint.new(width / 2, height / 2 )
15
+ @turtle_angle = 0
16
+ end
17
+
18
+
19
+ TexPlay::create_macro(:move_to) do |x, y|
20
+ capture {
21
+ @turtle_pos.x = x
22
+ @turtle_pos.y = y
23
+ }
24
+ end
25
+
26
+ TexPlay::create_macro(:move_rel) do |dx, dy|
27
+ capture {
28
+ @turtle_pos.x += dx
29
+ @turtle_pos.y += dy
30
+ }
31
+ end
32
+
33
+ TexPlay::create_macro(:line_to) do |x, y, *other|
34
+ capture {
35
+ line(@turtle_pos.x, @turtle_pos.y, x, y, *other)
36
+
37
+ @turtle_pos.x, @turtle_pos.y = x, y
38
+ }
39
+ end
40
+
41
+ TexPlay::create_macro(:line_rel) do |dx, dy, *other|
42
+ capture {
43
+ x = @turtle_pos.x + dx
44
+ y = @turtle_pos.y + dy
45
+
46
+ line(@turtle_pos.x, @turtle_pos.y, x, y, *other)
47
+
48
+ @turtle_pos.x, @turtle_pos.y = x, y
49
+ }
50
+ end
51
+
52
+ TexPlay::create_macro(:turn_to) do |a|
53
+ capture {
54
+ @turtle_angle = a
55
+ }
56
+ end
57
+
58
+ TexPlay::create_macro(:turn) do |da|
59
+ capture {
60
+ @turtle_angle += da
61
+ }
62
+ end
63
+
64
+ TexPlay::create_macro(:forward) do |dist, *other|
65
+ capture {
66
+ visible = other.shift
67
+
68
+ radians_per_degree = 0.0174532925199433
69
+
70
+ x = @turtle_pos.x + dist * Math::cos(radians_per_degree * @turtle_angle)
71
+ y = @turtle_pos.y + dist * Math::sin(radians_per_degree * @turtle_angle)
72
+
73
+ if(visible) then
74
+ line_to(x, y, *other)
75
+ else
76
+ move_to(x, y)
77
+ end
78
+ }
79
+ end
80
+
81
+ ## L-System code
82
+
83
+ # monkeypatches to TexPlay class
84
+ module TexPlay
85
+ class LSystem
86
+ def initialize(&block)
87
+ @rules = {}
88
+
89
+ instance_eval(&block) if block
90
+ end
91
+
92
+ def rule(new_rule)
93
+ @rules.merge!(new_rule)
94
+ end
95
+
96
+ def atom(new_atom)
97
+ @atom = new_atom
98
+ end
99
+
100
+ def angle(new_angle=nil)
101
+ return @angle if !new_angle
102
+ @angle = new_angle
103
+ end
104
+
105
+ def produce_string(order)
106
+ order = order[:order]
107
+ string = @atom.dup
108
+
109
+ order.times do
110
+ i = 0
111
+ while(i < string.length)
112
+ sub = @rules[string[i, 1]]
113
+
114
+ string[i] = sub if sub
115
+
116
+ i += sub ? sub.length : 1
117
+ end
118
+ end
119
+
120
+ string
121
+ end
122
+ end
123
+ end
124
+
125
+ # L-System macro
126
+ TexPlay::create_macro(:lsystem) do |x, y, system, options|
127
+ capture {
128
+ theta = system.angle
129
+ turtle_stack = []
130
+ move_to(x, y)
131
+ line_length = options[:line_length] || 1
132
+
133
+ system.produce_string(options).each_char do |v|
134
+
135
+ case v
136
+ when "F"
137
+ forward(line_length, true)
138
+ when "+"
139
+ turn(theta)
140
+ when "-"
141
+ turn(-theta)
142
+ when "["
143
+ turtle_stack.push([@turtle_pos.dup, @turtle_angle])
144
+ when "]"
145
+ @turtle_pos, @turtle_angle = turtle_stack.pop
146
+ end
147
+ end
148
+ }
149
+ end
data/lib/texplay.rb CHANGED
@@ -1,134 +1,134 @@
1
- # (C) John Mair 2009, under the MIT licence
2
-
3
- begin
4
- require 'rubygems'
5
- rescue LoadError
6
- end
7
-
8
- # include gosu first
9
- require 'rbconfig'
10
- require 'gosu'
11
-
12
- module TexPlay
13
- TEXPLAY_VERSION = "0.2.2"
14
-
15
- def self::on_setup(&block)
16
- raise "need a block" if !block
17
-
18
- @__init_procs__ ||= []
19
- @__init_procs__.push(block)
20
- end
21
-
22
- def self::setup(receiver)
23
- if @__init_procs__ then
24
- @__init_procs__.each do |init_proc|
25
- receiver.instance_eval(&init_proc)
26
- end
27
- end
28
- end
29
-
30
- def self::create_blank_image(window, width, height)
31
- Gosu::Image.new(window, EmptyImageStub.new(width, height))
32
- end
33
-
34
- module Colors
35
- Red = [1, 0, 0, 1]
36
- Green = [0, 1, 0, 1]
37
- Blue = [0, 0, 1, 1]
38
- Black = [0, 0, 0, 1]
39
- White = [1, 1, 1, 1]
40
- Grey = [0.5, 0.5, 0.5, 1]
41
- Alpha = [0, 0, 0, 0]
42
- Purple = [1, 0, 1, 1]
43
- Yellow = [1, 1, 0, 1]
44
- Cyan = [0, 1, 1, 1]
45
- Orange = [1, 0.5, 0, 1]
46
- Brown = [0.39, 0.26, 0.13, 1]
47
- Turquoise = [1, 0.6, 0.8, 1]
48
- Tyrian = [0.4, 0.007, 0.235, 1]
49
- end
50
- include Colors
51
- end
52
-
53
- # credit to philomory for this class
54
- class EmptyImageStub
55
- def initialize(w, h)
56
- @w, @h = w, h
57
- end
58
-
59
- def to_blob
60
- "\0" * @w * @h * 4
61
- end
62
-
63
- def rows
64
- @h
65
- end
66
-
67
- def columns
68
- @w
69
- end
70
- end
71
-
72
- # bring in user-defined extensions to TexPlay
73
- direc = File.dirname(__FILE__)
74
- dlext = Config::CONFIG['DLEXT']
75
- begin
76
- if RUBY_VERSION && RUBY_VERSION =~ /1.9/
77
- require "#{direc}/ctexplay.19.#{dlext}"
78
- else
79
- require "#{direc}/ctexplay.18.#{dlext}"
80
- end
81
- rescue LoadError => e
82
- require "#{direc}/ctexplay.#{dlext}"
83
- end
84
-
85
- require "#{direc}/texplay-contrib"
86
-
87
- # monkey patching the Gosu::Image class to add image manipulation functionality
88
- module Gosu
89
- class Image
90
-
91
- # bring in the TexPlay image manipulation methods
92
- include TexPlay
93
-
94
- class << self
95
- alias_method :original_new, :new
96
-
97
- def new(*args, &block)
98
-
99
- # invoke old behaviour
100
- obj = original_new(*args, &block)
101
-
102
- # refresh the TexPlay image cache
103
- if obj.width <= (TexPlay::TP_MAX_QUAD_SIZE - 2) &&
104
- obj.height <= (TexPlay::TP_MAX_QUAD_SIZE - 2) && obj.quad_cached? then
105
-
106
- obj.refresh_cache
107
- end
108
-
109
- # run custom setup
110
- TexPlay::setup(obj)
111
-
112
- obj.instance_variable_set(:@__window__, args.first)
113
-
114
- # return the new image
115
- obj
116
- end
117
- end
118
-
119
- def __window__
120
- @__window__
121
- end
122
- end
123
- end
124
-
125
- # a bug in ruby 1.8.6 rb_eval_string() means i must define this here (rather than in texplay.c)
126
- class Proc
127
- def __context__
128
- eval('self', self.binding)
129
- end
130
- end
131
-
132
-
133
-
134
-
1
+ # (C) John Mair 2009, under the MIT licence
2
+
3
+ begin
4
+ require 'rubygems'
5
+ rescue LoadError
6
+ end
7
+
8
+ # include gosu first
9
+ require 'rbconfig'
10
+ require 'gosu'
11
+
12
+ module TexPlay
13
+ TEXPLAY_VERSION = "0.2.4"
14
+
15
+ def self::on_setup(&block)
16
+ raise "need a block" if !block
17
+
18
+ @__init_procs__ ||= []
19
+ @__init_procs__.push(block)
20
+ end
21
+
22
+ def self::setup(receiver)
23
+ if @__init_procs__ then
24
+ @__init_procs__.each do |init_proc|
25
+ receiver.instance_eval(&init_proc)
26
+ end
27
+ end
28
+ end
29
+
30
+ def self::create_blank_image(window, width, height)
31
+ Gosu::Image.new(window, EmptyImageStub.new(width, height))
32
+ end
33
+
34
+ module Colors
35
+ Red = [1, 0, 0, 1]
36
+ Green = [0, 1, 0, 1]
37
+ Blue = [0, 0, 1, 1]
38
+ Black = [0, 0, 0, 1]
39
+ White = [1, 1, 1, 1]
40
+ Grey = [0.5, 0.5, 0.5, 1]
41
+ Alpha = [0, 0, 0, 0]
42
+ Purple = [1, 0, 1, 1]
43
+ Yellow = [1, 1, 0, 1]
44
+ Cyan = [0, 1, 1, 1]
45
+ Orange = [1, 0.5, 0, 1]
46
+ Brown = [0.39, 0.26, 0.13, 1]
47
+ Turquoise = [1, 0.6, 0.8, 1]
48
+ Tyrian = [0.4, 0.007, 0.235, 1]
49
+ end
50
+ include Colors
51
+ end
52
+
53
+ # credit to philomory for this class
54
+ class EmptyImageStub
55
+ def initialize(w, h)
56
+ @w, @h = w, h
57
+ end
58
+
59
+ def to_blob
60
+ "\0" * @w * @h * 4
61
+ end
62
+
63
+ def rows
64
+ @h
65
+ end
66
+
67
+ def columns
68
+ @w
69
+ end
70
+ end
71
+
72
+ # bring in user-defined extensions to TexPlay
73
+ direc = File.dirname(__FILE__)
74
+ dlext = Config::CONFIG['DLEXT']
75
+ begin
76
+ if RUBY_VERSION && RUBY_VERSION =~ /1.9/
77
+ require "#{direc}/ctexplay.19.#{dlext}"
78
+ else
79
+ require "#{direc}/ctexplay.18.#{dlext}"
80
+ end
81
+ rescue LoadError => e
82
+ require "#{direc}/ctexplay.#{dlext}"
83
+ end
84
+
85
+ require "#{direc}/texplay-contrib"
86
+
87
+ # monkey patching the Gosu::Image class to add image manipulation functionality
88
+ module Gosu
89
+ class Image
90
+
91
+ # bring in the TexPlay image manipulation methods
92
+ include TexPlay
93
+
94
+ class << self
95
+ alias_method :original_new, :new
96
+
97
+ def new(*args, &block)
98
+
99
+ # invoke old behaviour
100
+ obj = original_new(*args, &block)
101
+
102
+ # refresh the TexPlay image cache
103
+ if obj.width <= (TexPlay::TP_MAX_QUAD_SIZE - 2) &&
104
+ obj.height <= (TexPlay::TP_MAX_QUAD_SIZE - 2) && obj.quad_cached? then
105
+
106
+ obj.refresh_cache
107
+ end
108
+
109
+ # run custom setup
110
+ TexPlay::setup(obj)
111
+
112
+ obj.instance_variable_set(:@__window__, args.first)
113
+
114
+ # return the new image
115
+ obj
116
+ end
117
+ end
118
+
119
+ def __window__
120
+ @__window__
121
+ end
122
+ end
123
+ end
124
+
125
+ # a bug in ruby 1.8.6 rb_eval_string() means i must define this here (rather than in texplay.c)
126
+ class Proc
127
+ def __context__
128
+ eval('self', self.binding)
129
+ end
130
+ end
131
+
132
+
133
+
134
+
data/src/Makefile CHANGED
@@ -53,7 +53,7 @@ warnflags =
53
53
  CFLAGS = -MD -Zi -O2b2xg- -G6 -Zm600
54
54
  INCFLAGS = -I. -I$(arch_hdrdir) -I$(hdrdir)/ruby/backward -I$(hdrdir) -I$(srcdir)
55
55
  DEFS =
56
- CPPFLAGS =
56
+ CPPFLAGS = -DRUBY_19
57
57
  CXXFLAGS = $(CFLAGS) -MD -Zi -O2b2xg- -G6 -Zm600
58
58
  ldflags = -incremental:no -debug -opt:ref -opt:icf
59
59
  dldflags = -incremental:no -debug -opt:ref -opt:icf -dll $(LIBPATH)
data/src/actions.obj CHANGED
Binary file
data/src/bindings.obj CHANGED
Binary file
data/src/cache.obj CHANGED
Binary file
data/src/compat.h CHANGED
@@ -6,9 +6,13 @@
6
6
  #include <ruby.h>
7
7
 
8
8
  /* this is the test we use to identify ruby 1.9.1 */
9
+
10
+ /* commenting out this test because it doesn't seem to work in 1.8.7 */
11
+ /*
9
12
  #ifdef RCLASS_M_TBL
10
13
  # define RUBY_19
11
14
  #endif
15
+ */
12
16
 
13
17
  /* macros for backwards compatibility with 1.8 */
14
18
  #ifndef RUBY_19
Binary file
Binary file
Binary file
data/src/ctexplay.so CHANGED
Binary file
data/src/extconf.rb CHANGED
@@ -15,4 +15,7 @@ else
15
15
  exit unless have_library("glut32")
16
16
  end
17
17
 
18
+ # 1.9 compatibility
19
+ $CPPFLAGS += " -DRUBY_19" if RUBY_VERSION =~ /1.9/
20
+
18
21
  create_makefile('ctexplay')
data/src/gen_eval.obj CHANGED
Binary file
Binary file
data/src/texplay.obj CHANGED
Binary file
data/src/utils.c CHANGED
@@ -946,10 +946,26 @@ fact(int n)
946
946
  }
947
947
 
948
948
  unsigned
949
- comb(int n, int k)
949
+ comb(int n, int r)
950
950
  {
951
- double temp = fact(n) / (fact(k) * fact(n - k));
951
+ double temp = fact(n) / (fact(r) * fact(n - r));
952
952
  return temp;
953
+ /* if(r > (n / 2))
954
+ r = n - r;
955
+
956
+ return perm(n, r) / fact(r);
957
+ */
958
+ }
959
+
960
+ unsigned
961
+ perm(int n, int r)
962
+ {
963
+ int val = n;
964
+ int i;
965
+ for(i = n - 1; i > (n - r); i--)
966
+ val *= i;
967
+
968
+ return val;
953
969
  }
954
970
 
955
971
  double
data/src/utils.h CHANGED
@@ -138,6 +138,8 @@ VALUE point_y(VALUE point);
138
138
  double power(float base, int exp);
139
139
  unsigned fact(int n);
140
140
  unsigned comb(int n, int k);
141
+ unsigned perm(int n, int r);
142
+
141
143
  double bernstein(int n, int k, float u);
142
144
 
143
145
  #endif
data/src/utils.obj CHANGED
Binary file
data/src/vc60.pdb CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: texplay
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.4
5
5
  platform: x86-mswin32-60
6
6
  authors:
7
7
  - John Mair (banisterfiend)
@@ -34,7 +34,6 @@ files:
34
34
  - Rakefile
35
35
  - README.markdown
36
36
  - CHANGELOG
37
- - README1st
38
37
  - lib/texplay.rb
39
38
  - lib/texplay-contrib.rb
40
39
  - src/actions.c
@@ -82,6 +81,7 @@ files:
82
81
  - examples/example_fluent.rb
83
82
  - examples/example_gen_eval.rb
84
83
  - examples/example_hash_arguments.rb
84
+ - examples/example_lsystem.rb
85
85
  - examples/example_melt.rb
86
86
  - examples/example_polyline.rb
87
87
  - examples/example_simple.rb
data/README1st DELETED
@@ -1,9 +0,0 @@
1
- INSTRUCTIONS
2
-
3
- TexPlay version 0.2.2
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
-