texplay 0.2.720-i386-mswin32

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 ADDED
@@ -0,0 +1,115 @@
1
+ 6/12/09
2
+ version 0.2.710
3
+ * fixed bug in line drawing code (wasn't drawing final pixel)
4
+ * fixed bug in filled rect code (wasn't drawing final row)
5
+ * fixed bug in flood fill (wasn't drawing on first column)
6
+ * added glDisable(GL_TEXTURE_2D) calls to cache.c, and removed 'restore previous texture binding' (i doubt there is any previous binding to restore)
7
+ * using version.rb to help manage versions
8
+
9
+ 23/11/09
10
+ * fixed bug in texplay.rb. Replaced TexPlay::TP_MAX_QUAD_SIZE - 2 with
11
+ just TexPlay::TP_MAX_QUAD_SIZE (the -2 is now built into the constant)
12
+
13
+ 16/10/09
14
+ version 0.2.700
15
+ * removed memory leak from Gosu::Image#to_blob, now writing directly to RSTRING_PTR
16
+
17
+ 12/10/09
18
+ version 0.2.666
19
+ * added Gosu::Image#to_blob
20
+ * to_blob functionality enables Gosu::Images to work with DevIL library
21
+
22
+ 6/10/09
23
+ version 0.2.5
24
+ * fixed quad_draw flicker bug
25
+ * added splice_and_scale (to texplay-contrib.rb)
26
+ * now using rake-compiler to run build process
27
+
28
+ 15/9/09
29
+ version 0.2.4
30
+ * added lsystem
31
+ * made lsystem both 1.9.1 and 1.8.6 compatible
32
+
33
+ 11/9/09
34
+ version 0.2.3
35
+ * added Ruby 1.8.7 compatibility by modifying extconf.rb to define RUBY_19 macro
36
+ * and modified compat.h to get rid of feature test (fails on 1.8.7)
37
+
38
+ 8/9/09
39
+ version 0.2.2
40
+ * fixed color_control bug, action_struct->color was being overwritten (now using a temp).
41
+ * fixed faulty error msg where max tex size was being displayed as 1024 but is actually 1022
42
+ * added :start_angle parameter to ngon action
43
+ * fixed example screen height from 769 to 768
44
+ * arity of -1 and 0 now supported for color_control procs
45
+ * fixed parameter checks for circle and ngon
46
+ * updated documentation to reflect changes, and added details on caching
47
+
48
+ 2/9/09
49
+ version 0.2.1
50
+ * releasing a gem for TexPlay
51
+ * bumped version number so can add add gosu 0.7.14 dependency to github gem
52
+ * hopefully gem works on both github and rubyforge
53
+ 31/8/09
54
+ version 0.2.0
55
+ * added each iterator
56
+ * added alternative to proc for :color_control proc (allowing static linear transforms to pixels)
57
+ * no longer segfaulting on windows (no idea why not)
58
+ * rewrote EmptyImageStub in ruby, using philomory's code. now alot faster.
59
+ * implemented 'shadow' in terms of static :color_control pixel transform
60
+ * added more example code demonstrating each iterator (example_each.rb) and new color_control behaviour
61
+ i.e example_color_transform.rb
62
+ * should be relatively stable now!
63
+
64
+ 28/8/09
65
+ version 0.1.9.1 (still BETA)
66
+ * experimental features: Gosu::Image#dup and Gosu::Image#clone
67
+ * also TexPlay::create_blank_image(window, width, height)
68
+ * I noticed these features SEG FAULT on my setup in windows, so be warned
69
+ * This is a BETA release
70
+
71
+ 14/8/09
72
+ version 0.1.9.0 (BETA)
73
+ * major rewrite. TP now supports beziers, polylines, polygons, and more
74
+ * also supports alpha_blending (though still tempermental)
75
+ * This is a BETA release
76
+
77
+ 1/7/09
78
+ version 0.1.6.2
79
+ * fixed another subtle bug in constrain_local_boundaries(). Function was
80
+ unable to deal with drawing actions that were 100% outside the image
81
+ boundaries.
82
+
83
+ 28/6/09
84
+ version 0.1.6
85
+ * gen_eval now working as a replacement for instance_eval in the #paint block. Allows for more user-friendly interface.
86
+ * #paint can now be called without a block; if invoked this way it executes any commands in the action queue, e.g
87
+ @img.circle 20, 20, 40
88
+ @img.pixel 30, 30
89
+ @img.paint
90
+ * above will function as if: @img.paint { circle 20, 20, 40; pixel 30, 30 }
91
+ * collected 1.8.6/1.9.1 compatibility into compat.h
92
+
93
+ 16/6/09
94
+ version 0.1.4.6
95
+ * allowed arity of 0 (as well as -1) for ruby 1.9 compatibility
96
+
97
+ 13/6/09
98
+ version 0.1.4.5
99
+ * major bugfix with TexPlay#splice method (segfaut). Also added new color format parameter: color [1, 1, 0, 1] (e.g purple with full alpha).
100
+ Also fixed subtle edge-case bug in constrain_local_boundaries().
101
+
102
+ 9/6/09
103
+ version 0.1.4
104
+ * improved error checking. should work better with later gosu releases
105
+
106
+ 20/2/09
107
+ version 0.1.1
108
+ * rerelease of this version fixing the oversized image bug for refresh_cache (i.e images over 500 x 500
109
+
110
+ version 0.1.1
111
+ * oops, bug in leftshift/rightshift functions, fixed!
112
+
113
+ version 0.1.0
114
+ * release!
115
+
data/README.markdown ADDED
@@ -0,0 +1,41 @@
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.710**
9
+
10
+ Gem installation:
11
+
12
+ + sudo gem install texplay
13
+
14
+ How to build the gems? (maintainers only)
15
+
16
+ + Install rake-compiler (http://github.com/luislavena/rake-compiler)
17
+ + Install 1.9.1 and 1.8.6 mingw ruby versions (instructions above)
18
+ + Type: rake cross native gem RUBY_CC_VERSION=1.8.6:1.9.1
19
+ + Upload new gems to rubyforge and gemcutter.
20
+
21
+ How to build from source?
22
+ + rake compile
23
+
24
+ OR
25
+
26
+ + rake19 compile (assuming this is the name of your 1.9.1 version of rake)
27
+
28
+ **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!
29
+
30
+ If all goes well, run the example programs:
31
+
32
+ + cd examples
33
+ + ruby example_melt.rb
34
+ + ruby example_simple.rb
35
+ + ..etc
36
+
37
+ + like any gosu application, gosu.so must be in the current directory (or the gosu gem installed) when running the examples.
38
+
39
+
40
+ ---
41
+ Enjoy!
data/Rakefile ADDED
@@ -0,0 +1,68 @@
1
+
2
+ require 'rake/clean'
3
+ require 'rake/gempackagetask'
4
+ require 'rake/extensiontask'
5
+
6
+ # get the texplay version
7
+ require 'lib/texplay/version'
8
+
9
+ $dlext = Config::CONFIG['DLEXT']
10
+
11
+ CLEAN.include("ext/**/*.#{$dlext}", "ext/**/*.log", "ext/**/*.o", "ext/**/*~", "ext/**/*#*", "ext/**/*.obj", "ext/**/*.def", "ext/**/*.pdb")
12
+ CLOBBER.include("**/*.#{$dlext}", "**/*~", "**/*#*", "**/*.log", "**/*.o")
13
+
14
+ specification = Gem::Specification.new do |s|
15
+ s.name = "texplay"
16
+ s.summary = "TexPlay is a light-weight image manipulation framework for Ruby and Gosu"
17
+ s.version = TexPlay::VERSION
18
+ s.date = Time.now.strftime '%Y-%m-%d'
19
+ s.author = "John Mair (banisterfiend)"
20
+ s.email = 'jrmair@gmail.com'
21
+ s.description = s.summary
22
+ s.require_path = 'lib'
23
+ s.add_dependency("gosu",">=0.7.14")
24
+ s.platform = Gem::Platform::RUBY
25
+ s.homepage = "http://banisterfiend.wordpress.com/2008/08/23/texplay-an-image-manipulation-tool-for-ruby-and-gosu/"
26
+ s.has_rdoc = false
27
+
28
+ s.extensions = ["ext/texplay/extconf.rb"]
29
+ s.files = ["Rakefile", "README.markdown", "CHANGELOG",
30
+ "lib/texplay.rb", "lib/texplay-contrib.rb", "lib/texplay/version.rb"] +
31
+ FileList["ext/**/extconf.rb", "ext/**/*.h", "ext/**/*.c", "examples/*.rb",
32
+ "examples/media/*"].to_a
33
+ end
34
+
35
+ Rake::ExtensionTask.new('texplay', specification) do |ext|
36
+ # ext.config_script = 'extconf.rb'
37
+ # ext.cross_compile = true
38
+ #ext.cross_platform = 'i386-mswin32'
39
+ # ext.platform = 'i386-mswin32'
40
+ end
41
+
42
+
43
+
44
+ specification = Gem::Specification.new do |s|
45
+ s.name = "texplay"
46
+ s.summary = "TexPlay is a light-weight image manipulation framework for Ruby and Gosu"
47
+ s.version = TexPlay::VERSION
48
+ s.date = Time.now.strftime '%Y-%m-%d'
49
+ s.author = "John Mair (banisterfiend)"
50
+ s.email = 'jrmair@gmail.com'
51
+ s.description = s.summary
52
+ s.require_path = 'lib'
53
+ s.add_dependency("gosu",">=0.7.14")
54
+ s.platform = 'i386-mswin32'
55
+ s.homepage = "http://banisterfiend.wordpress.com/2008/08/23/texplay-an-image-manipulation-tool-for-ruby-and-gosu/"
56
+ s.has_rdoc = false
57
+
58
+ s.files = ["Rakefile", "README.markdown", "CHANGELOG",
59
+ "lib/texplay.rb", "lib/texplay-contrib.rb", "lib/texplay/version.rb", "lib/1.8/texplay.so",
60
+ "lib/1.9/texplay.so"]
61
+ FileList["examples/*.rb",
62
+ "examples/media/*"].to_a
63
+ end
64
+
65
+ Rake::GemPackageTask.new(specification) do |package|
66
+ package.need_zip = false
67
+ package.need_tar = false
68
+ end
Binary file
Binary file
@@ -0,0 +1,3 @@
1
+ module TexPlay
2
+ VERSION = "0.2.720"
3
+ end
@@ -0,0 +1,171 @@
1
+ begin
2
+ require 'rubygems'
3
+ rescue LoadError
4
+ end
5
+
6
+ require 'texplay'
7
+
8
+ # to bring in String#each_char for 1.8
9
+ if RUBY_VERSION =~ /1.8/
10
+ require 'jcode'
11
+ end
12
+
13
+ # setup will be executed straight after Gosu::Image instantiation
14
+ TexPlay::on_setup do
15
+ @turtle_pos = TexPlay::TPPoint.new(width / 2, height / 2 )
16
+ @turtle_angle = 0
17
+ end
18
+
19
+
20
+ TexPlay::create_macro(:move_to) do |x, y|
21
+ capture {
22
+ @turtle_pos.x = x
23
+ @turtle_pos.y = y
24
+ }
25
+ end
26
+
27
+ TexPlay::create_macro(:move_rel) do |dx, dy|
28
+ capture {
29
+ @turtle_pos.x += dx
30
+ @turtle_pos.y += dy
31
+ }
32
+ end
33
+
34
+ TexPlay::create_macro(:line_to) do |x, y, *other|
35
+ capture {
36
+ line(@turtle_pos.x, @turtle_pos.y, x, y, *other)
37
+
38
+ @turtle_pos.x, @turtle_pos.y = x, y
39
+ }
40
+ end
41
+
42
+ TexPlay::create_macro(:line_rel) do |dx, dy, *other|
43
+ capture {
44
+ x = @turtle_pos.x + dx
45
+ y = @turtle_pos.y + dy
46
+
47
+ line(@turtle_pos.x, @turtle_pos.y, x, y, *other)
48
+
49
+ @turtle_pos.x, @turtle_pos.y = x, y
50
+ }
51
+ end
52
+
53
+ TexPlay::create_macro(:turn_to) do |a|
54
+ capture {
55
+ @turtle_angle = a
56
+ }
57
+ end
58
+
59
+ TexPlay::create_macro(:turn) do |da|
60
+ capture {
61
+ @turtle_angle += da
62
+ }
63
+ end
64
+
65
+ TexPlay::create_macro(:forward) do |dist, *other|
66
+ capture {
67
+ visible = other.shift
68
+
69
+ radians_per_degree = 0.0174532925199433
70
+
71
+ x = @turtle_pos.x + dist * Math::cos(radians_per_degree * @turtle_angle)
72
+ y = @turtle_pos.y + dist * Math::sin(radians_per_degree * @turtle_angle)
73
+
74
+ if(visible) then
75
+ line_to(x, y, *other)
76
+ else
77
+ move_to(x, y)
78
+ end
79
+ }
80
+ end
81
+
82
+ # L-System code
83
+ # adding LSystem class to TexPlay module
84
+ class TexPlay::LSystem
85
+ def initialize(&block)
86
+ @rules = {}
87
+
88
+ instance_eval(&block) if block
89
+ end
90
+
91
+ def rule(new_rule)
92
+ @rules.merge!(new_rule)
93
+ end
94
+
95
+ def atom(new_atom)
96
+ @atom = new_atom
97
+ end
98
+
99
+ def angle(new_angle=nil)
100
+ return @angle if !new_angle
101
+ @angle = new_angle
102
+ end
103
+
104
+ def produce_string(order)
105
+ order = order[:order]
106
+ string = @atom.dup
107
+
108
+ order.times do
109
+ i = 0
110
+ while(i < string.length)
111
+ sub = @rules[string[i, 1]]
112
+
113
+ string[i] = sub if sub
114
+
115
+ i += sub ? sub.length : 1
116
+ end
117
+ end
118
+
119
+ string
120
+ end
121
+ end
122
+
123
+ # L-System macro
124
+ TexPlay::create_macro(:lsystem) do |x, y, system, options|
125
+ capture {
126
+ theta = system.angle
127
+ turtle_stack = []
128
+ move_to(x, y)
129
+ line_length = options[:line_length] || 1
130
+
131
+ system.produce_string(options).each_char do |v|
132
+
133
+ case v
134
+ when "F"
135
+ forward(line_length, true)
136
+ when "+"
137
+ turn(theta)
138
+ when "-"
139
+ turn(-theta)
140
+ when "["
141
+ turtle_stack.push([@turtle_pos.dup, @turtle_angle])
142
+ when "]"
143
+ @turtle_pos, @turtle_angle = turtle_stack.pop
144
+ end
145
+ end
146
+ }
147
+ end
148
+
149
+ # Scaling
150
+ # uses nearest-neighbour
151
+ TexPlay::create_macro(:splice_and_scale) do |img, cx, cy, *options|
152
+ options = options.first ? options.first : {}
153
+
154
+ options = {
155
+ :color_control => proc do |c1, c2, x, y|
156
+ factor = options[:factor] || 1
157
+ factor_x = options[:factor_x] || factor
158
+ factor_y = options[:factor_y] || factor
159
+
160
+ x = factor_x * (x - cx) + cx
161
+ y = factor_y * (y - cy) + cy
162
+
163
+ rect x, y, x + factor_x, y + factor_y, :color => c2, :fill => true
164
+ :none
165
+ end
166
+ }.merge!(options)
167
+
168
+ splice img, cx, cy, options
169
+
170
+ self
171
+ end
data/lib/texplay.rb ADDED
@@ -0,0 +1,137 @@
1
+ # (C) John Mair 2009, under the MIT licence
2
+
3
+ begin
4
+ require 'rubygems'
5
+ rescue LoadError
6
+ end
7
+
8
+ direc = File.dirname(__FILE__)
9
+
10
+ # include gosu first
11
+ require 'rbconfig'
12
+ require 'gosu'
13
+ require "#{direc}/texplay/version"
14
+
15
+ module TexPlay
16
+ class << self
17
+ def on_setup(&block)
18
+ raise "need a block" if !block
19
+
20
+ @__init_procs__ ||= []
21
+ @__init_procs__.push(block)
22
+ end
23
+
24
+ def setup(receiver)
25
+ if @__init_procs__ then
26
+ @__init_procs__.each do |init_proc|
27
+ receiver.instance_eval(&init_proc)
28
+ end
29
+ end
30
+ end
31
+
32
+ def create_blank_image(window, width, height)
33
+ Gosu::Image.new(window, EmptyImageStub.new(width, height))
34
+ end
35
+
36
+ alias_method :create_image, :create_blank_image
37
+ end
38
+
39
+ module Colors
40
+ Red = [1, 0, 0, 1]
41
+ Green = [0, 1, 0, 1]
42
+ Blue = [0, 0, 1, 1]
43
+ Black = [0, 0, 0, 1]
44
+ White = [1, 1, 1, 1]
45
+ Grey = [0.5, 0.5, 0.5, 1]
46
+ Alpha = [0, 0, 0, 0]
47
+ Purple = [1, 0, 1, 1]
48
+ Yellow = [1, 1, 0, 1]
49
+ Cyan = [0, 1, 1, 1]
50
+ Orange = [1, 0.5, 0, 1]
51
+ Brown = [0.39, 0.26, 0.13, 1]
52
+ Turquoise = [1, 0.6, 0.8, 1]
53
+ Tyrian = [0.4, 0.007, 0.235, 1]
54
+ end
55
+ include Colors
56
+ end
57
+
58
+ # credit to philomory for this class
59
+ class EmptyImageStub
60
+ def initialize(w, h)
61
+ @w, @h = w, h
62
+ end
63
+
64
+ def to_blob
65
+ "\0" * @w * @h * 4
66
+ end
67
+
68
+ def rows
69
+ @h
70
+ end
71
+
72
+ def columns
73
+ @w
74
+ end
75
+ end
76
+
77
+ # bring in user-defined extensions to TexPlay
78
+ direc = File.dirname(__FILE__)
79
+ dlext = Config::CONFIG['DLEXT']
80
+ begin
81
+ if RUBY_VERSION && RUBY_VERSION =~ /1.9/
82
+ require "#{direc}/1.9/texplay.#{dlext}"
83
+ else
84
+ require "#{direc}/1.8/texplay.#{dlext}"
85
+ end
86
+ rescue LoadError => e
87
+ require "#{direc}/texplay.#{dlext}"
88
+ end
89
+
90
+ require "#{direc}/texplay-contrib"
91
+
92
+ # monkey patching the Gosu::Image class to add image manipulation functionality
93
+ module Gosu
94
+ class Image
95
+
96
+ # bring in the TexPlay image manipulation methods
97
+ include TexPlay
98
+
99
+ attr_reader :__window__
100
+
101
+ class << self
102
+ alias_method :original_new, :new
103
+
104
+ def new(*args, &block)
105
+
106
+ # invoke old behaviour
107
+ obj = original_new(*args, &block)
108
+
109
+ # refresh the TexPlay image cache
110
+ if obj.width <= (TexPlay::TP_MAX_QUAD_SIZE) &&
111
+ obj.height <= (TexPlay::TP_MAX_QUAD_SIZE) && obj.quad_cached? then
112
+
113
+ obj.refresh_cache
114
+ end
115
+
116
+ # run custom setup
117
+ TexPlay::setup(obj)
118
+
119
+ obj.instance_variable_set(:@__window__, args.first)
120
+
121
+ # return the new image
122
+ obj
123
+ end
124
+ end
125
+ end
126
+ end
127
+
128
+ # a bug in ruby 1.8.6 rb_eval_string() means i must define this here (rather than in texplay.c)
129
+ class Proc
130
+ def __context__
131
+ eval('self', self.binding)
132
+ end
133
+ end
134
+
135
+
136
+
137
+
metadata ADDED
@@ -0,0 +1,71 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: texplay
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.720
5
+ platform: i386-mswin32
6
+ authors:
7
+ - John Mair (banisterfiend)
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2010-03-13 00:00:00 +13:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: gosu
17
+ type: :runtime
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: 0.7.14
24
+ version:
25
+ description: TexPlay is a light-weight image manipulation framework for Ruby and Gosu
26
+ email: jrmair@gmail.com
27
+ executables: []
28
+
29
+ extensions: []
30
+
31
+ extra_rdoc_files: []
32
+
33
+ files:
34
+ - Rakefile
35
+ - README.markdown
36
+ - CHANGELOG
37
+ - lib/texplay.rb
38
+ - lib/texplay-contrib.rb
39
+ - lib/texplay/version.rb
40
+ - lib/1.8/texplay.so
41
+ - lib/1.9/texplay.so
42
+ has_rdoc: true
43
+ homepage: http://banisterfiend.wordpress.com/2008/08/23/texplay-an-image-manipulation-tool-for-ruby-and-gosu/
44
+ licenses: []
45
+
46
+ post_install_message:
47
+ rdoc_options: []
48
+
49
+ require_paths:
50
+ - lib
51
+ required_ruby_version: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ version: "0"
56
+ version:
57
+ required_rubygems_version: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: "0"
62
+ version:
63
+ requirements: []
64
+
65
+ rubyforge_project:
66
+ rubygems_version: 1.3.5
67
+ signing_key:
68
+ specification_version: 3
69
+ summary: TexPlay is a light-weight image manipulation framework for Ruby and Gosu
70
+ test_files: []
71
+