texplay 0.2.800 → 0.2.900

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.
Files changed (51) hide show
  1. data/CHANGELOG +138 -119
  2. data/README.markdown +43 -41
  3. data/Rakefile +68 -68
  4. data/examples/common.rb +8 -8
  5. data/examples/example_alpha_blend.rb +31 -31
  6. data/examples/example_bezier.rb +42 -42
  7. data/examples/example_color_control.rb +69 -69
  8. data/examples/example_color_transform.rb +64 -67
  9. data/examples/example_color_transform_circle.rb +65 -0
  10. data/examples/example_dup.rb +75 -75
  11. data/examples/example_each.rb +42 -42
  12. data/examples/example_effect.rb +35 -35
  13. data/examples/example_fill.rb +44 -44
  14. data/examples/example_fill_old.rb +49 -49
  15. data/examples/example_fluent.rb +31 -31
  16. data/examples/example_gen_eval.rb +34 -34
  17. data/examples/example_hash_arguments.rb +47 -47
  18. data/examples/example_light.rb +77 -0
  19. data/examples/example_lsystem.rb +61 -61
  20. data/examples/example_melt.rb +27 -27
  21. data/examples/example_meyet.rb +64 -0
  22. data/examples/example_polyline.rb +43 -43
  23. data/examples/example_scale.rb +29 -29
  24. data/examples/example_simple.rb +48 -38
  25. data/examples/example_sync.rb +60 -60
  26. data/examples/example_trace.rb +1 -1
  27. data/examples/example_turtle.rb +40 -40
  28. data/examples/example_weird.rb +3 -1
  29. data/examples/media/Thumbs.db +0 -0
  30. data/ext/texplay/actions.c +999 -1001
  31. data/ext/texplay/actions.h +60 -60
  32. data/ext/texplay/bindings.c +1162 -1149
  33. data/ext/texplay/bindings.h +46 -46
  34. data/ext/texplay/cache.c +118 -118
  35. data/ext/texplay/cache.h +24 -24
  36. data/ext/texplay/compat.h +27 -27
  37. data/ext/texplay/extconf.rb +28 -28
  38. data/ext/texplay/gen_eval.c +211 -211
  39. data/ext/texplay/gen_eval.h +20 -20
  40. data/ext/texplay/graphics_utils.c +188 -63
  41. data/ext/texplay/graphics_utils.h +0 -1
  42. data/ext/texplay/object2module.c +171 -171
  43. data/ext/texplay/object2module.h +11 -11
  44. data/ext/texplay/texplay.c +169 -169
  45. data/ext/texplay/texplay.h +147 -130
  46. data/ext/texplay/utils.c +816 -752
  47. data/ext/texplay/utils.h +151 -145
  48. data/lib/texplay-contrib.rb +171 -171
  49. data/lib/texplay.rb +162 -137
  50. data/lib/texplay/version.rb +1 -1
  51. metadata +9 -5
data/lib/texplay.rb CHANGED
@@ -1,137 +1,162 @@
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
-
1
+
2
+ # (C) John Mair 2009, under the MIT licence
3
+
4
+ begin
5
+ require 'rubygems'
6
+ rescue LoadError
7
+ end
8
+
9
+ direc = File.dirname(__FILE__)
10
+
11
+ # include gosu first
12
+ require 'rbconfig'
13
+ require 'gosu'
14
+ require "#{direc}/texplay/version"
15
+
16
+ module TexPlay
17
+ class << self
18
+ def on_setup(&block)
19
+ raise "need a block" if !block
20
+
21
+ @__init_procs__ ||= []
22
+ @__init_procs__.push(block)
23
+ end
24
+
25
+ def setup(receiver)
26
+ if @__init_procs__ then
27
+ @__init_procs__.each do |init_proc|
28
+ receiver.instance_eval(&init_proc)
29
+ end
30
+ end
31
+ end
32
+
33
+ def create_blank_image(window, width, height, options={})
34
+ options = { :color => [0, 0, 0, 0] }.merge!(options)
35
+
36
+ img = Gosu::Image.new(window, EmptyImageStub.new(width, height))
37
+ img.rect 0, 0, img.width - 1, img.height - 1, :color => options[:color], :fill => true
38
+
39
+ img
40
+ end
41
+
42
+ alias_method :create_image, :create_blank_image
43
+ end
44
+
45
+ module Colors
46
+ Red = [1, 0, 0, 1]
47
+ Green = [0, 1, 0, 1]
48
+ Blue = [0, 0, 1, 1]
49
+ Black = [0, 0, 0, 1]
50
+ White = [1, 1, 1, 1]
51
+ Grey = [0.5, 0.5, 0.5, 1]
52
+ Alpha = [0, 0, 0, 0]
53
+ Purple = [1, 0, 1, 1]
54
+ Yellow = [1, 1, 0, 1]
55
+ Cyan = [0, 1, 1, 1]
56
+ Orange = [1, 0.5, 0, 1]
57
+ Brown = [0.39, 0.26, 0.13, 1]
58
+ Turquoise = [1, 0.6, 0.8, 1]
59
+ Tyrian = [0.4, 0.007, 0.235, 1]
60
+ end
61
+ include Colors
62
+ end
63
+
64
+ # credit to philomory for this class
65
+ class EmptyImageStub
66
+ def initialize(w, h)
67
+ @w, @h = w, h
68
+ end
69
+
70
+ def to_blob
71
+ "\0" * @w * @h * 4
72
+ end
73
+
74
+ def rows
75
+ @h
76
+ end
77
+
78
+ def columns
79
+ @w
80
+ end
81
+ end
82
+
83
+ # bring in user-defined extensions to TexPlay
84
+ direc = File.dirname(__FILE__)
85
+ dlext = Config::CONFIG['DLEXT']
86
+ begin
87
+ if RUBY_VERSION && RUBY_VERSION =~ /1.9/
88
+ require "#{direc}/1.9/texplay.#{dlext}"
89
+ else
90
+ require "#{direc}/1.8/texplay.#{dlext}"
91
+ end
92
+ rescue LoadError => e
93
+ require "#{direc}/texplay.#{dlext}"
94
+ end
95
+
96
+ require "#{direc}/texplay-contrib"
97
+
98
+ # monkey patching the Gosu::Image class to add image manipulation functionality
99
+ module Gosu
100
+ class Image
101
+
102
+ # bring in the TexPlay image manipulation methods
103
+ include TexPlay
104
+
105
+ attr_reader :__window__
106
+
107
+ class << self
108
+ alias_method :original_new, :new
109
+
110
+ def new(*args, &block)
111
+
112
+ # invoke old behaviour
113
+ obj = original_new(*args, &block)
114
+
115
+ prepare_image(*args, obj)
116
+ end
117
+
118
+ alias_method :original_from_text, :from_text
119
+
120
+ def from_text(*args, &block)
121
+
122
+ # invoke old behaviour
123
+ obj = original_from_text(*args, &block)
124
+
125
+ prepare_image(*args, obj)
126
+ end
127
+
128
+ def prepare_image(*args, obj)
129
+
130
+ # refresh the TexPlay image cache
131
+ if obj.width <= (TexPlay::TP_MAX_QUAD_SIZE) &&
132
+ obj.height <= (TexPlay::TP_MAX_QUAD_SIZE) && obj.quad_cached? then
133
+
134
+ obj.refresh_cache
135
+ end
136
+
137
+ # run custom setup
138
+ TexPlay.setup(obj)
139
+
140
+ obj.instance_variable_set(:@__window__, args.first)
141
+
142
+ obj
143
+ end
144
+
145
+ private :prepare_image
146
+ end
147
+
148
+ alias_method :rows, :height
149
+ alias_method :columns, :width
150
+ end
151
+ end
152
+
153
+ # a bug in ruby 1.8.6 rb_eval_string() means i must define this here (rather than in texplay.c)
154
+ class Proc
155
+ def __context__
156
+ eval('self', self.binding)
157
+ end
158
+ end
159
+
160
+
161
+
162
+
@@ -1,3 +1,3 @@
1
1
  module TexPlay
2
- VERSION = "0.2.800"
2
+ VERSION = "0.2.900"
3
3
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 2
8
- - 800
9
- version: 0.2.800
8
+ - 900
9
+ version: 0.2.900
10
10
  platform: ruby
11
11
  authors:
12
12
  - John Mair (banisterfiend)
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-03-22 00:00:00 +13:00
17
+ date: 2010-06-07 00:00:00 +02:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -27,8 +27,8 @@ dependencies:
27
27
  segments:
28
28
  - 0
29
29
  - 7
30
- - 14
31
- version: 0.7.14
30
+ - 20
31
+ version: 0.7.20
32
32
  type: :runtime
33
33
  version_requirements: *id001
34
34
  description: TexPlay is a light-weight image manipulation framework for Ruby and Gosu
@@ -69,6 +69,7 @@ files:
69
69
  - examples/example_bezier.rb
70
70
  - examples/example_color_control.rb
71
71
  - examples/example_color_transform.rb
72
+ - examples/example_color_transform_circle.rb
72
73
  - examples/example_dup.rb
73
74
  - examples/example_each.rb
74
75
  - examples/example_effect.rb
@@ -77,8 +78,10 @@ files:
77
78
  - examples/example_fluent.rb
78
79
  - examples/example_gen_eval.rb
79
80
  - examples/example_hash_arguments.rb
81
+ - examples/example_light.rb
80
82
  - examples/example_lsystem.rb
81
83
  - examples/example_melt.rb
84
+ - examples/example_meyet.rb
82
85
  - examples/example_polyline.rb
83
86
  - examples/example_scale.rb
84
87
  - examples/example_simple.rb
@@ -98,6 +101,7 @@ files:
98
101
  - examples/media/sand1.png
99
102
  - examples/media/sunset.png
100
103
  - examples/media/texplay.png
104
+ - examples/media/Thumbs.db
101
105
  has_rdoc: true
102
106
  homepage: http://banisterfiend.wordpress.com/2008/08/23/texplay-an-image-manipulation-tool-for-ruby-and-gosu/
103
107
  licenses: []