texplay 0.2.983pre2 → 0.3.0

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 (47) hide show
  1. data/Rakefile +48 -56
  2. data/examples/common.rb +13 -2
  3. data/examples/example_alpha_blend.rb +1 -3
  4. data/examples/example_bezier.rb +1 -2
  5. data/examples/example_blank.rb +1 -3
  6. data/examples/example_cache.rb +1 -3
  7. data/examples/example_color_transform.rb +1 -3
  8. data/examples/example_color_transform_circle.rb +1 -3
  9. data/examples/example_darken.rb +1 -4
  10. data/examples/example_dup.rb +1 -4
  11. data/examples/example_each.rb +1 -4
  12. data/examples/example_effect.rb +1 -2
  13. data/examples/example_fill.rb +1 -2
  14. data/examples/example_fill_old.rb +1 -2
  15. data/examples/example_fluent.rb +1 -3
  16. data/examples/example_font.rb +1 -3
  17. data/examples/example_gen_eval.rb +1 -2
  18. data/examples/example_hash_arguments.rb +1 -2
  19. data/examples/example_ippa.rb +1 -3
  20. data/examples/example_light.rb +1 -3
  21. data/examples/example_light_multiply.rb +1 -3
  22. data/examples/example_lsystem.rb +1 -1
  23. data/examples/example_melt.rb +1 -3
  24. data/examples/example_meyet.rb +1 -3
  25. data/examples/example_polyline.rb +1 -2
  26. data/examples/example_scale.rb +1 -3
  27. data/examples/example_select.rb +1 -3
  28. data/examples/example_select2.rb +1 -4
  29. data/examples/example_simple.rb +1 -3
  30. data/examples/example_splice.rb +2 -4
  31. data/examples/example_sync.rb +1 -2
  32. data/examples/example_tiles.rb +1 -3
  33. data/examples/example_trace.rb +1 -2
  34. data/examples/example_transparent.rb +1 -3
  35. data/examples/example_transparent2.rb +1 -3
  36. data/examples/example_transparent3.rb +1 -3
  37. data/examples/example_turtle.rb +1 -2
  38. data/examples/example_weird.rb +1 -2
  39. data/examples/example_window_render_to_image.rb +41 -0
  40. data/examples/example_window_to_blob.rb +2 -5
  41. data/ext/texplay/utils.c +0 -5
  42. data/lib/texplay.rb +271 -165
  43. data/lib/texplay/c_function_docs.rb +189 -0
  44. data/lib/texplay/version.rb +1 -1
  45. metadata +13 -19
  46. data/examples/example_window_to_texture.rb +0 -55
  47. data/lib/texplay/patches.rb +0 -4
@@ -0,0 +1,189 @@
1
+ # This code is never run; it is just here so we can document the C functions.
2
+
3
+
4
+ module TexPlay
5
+ # Draw a bezier curve.
6
+ #
7
+ # @param (see #polyline)
8
+ # @option (see #polyline)
9
+ # @return [Gosu::Image]
10
+ def bezier(points, options = {})
11
+ end
12
+
13
+ # Draw a circle.
14
+ #
15
+ # @note :thickness not implemented for circle.
16
+ #
17
+ # @param [Number] center_x Horizontal center.
18
+ # @param [Number] center_y Vertical center.
19
+ # @param [Number] radius Radius.
20
+ # @option (see #set_pixel)
21
+ # @option options [Boolean] :fill (false) Whether to fill in the shape.
22
+ # @option options [Boolean] :filled (false) Synonym for +:fill+
23
+ # @return [Gosu::Image]
24
+ def circle(center_x, center_y, radius, options = {})
25
+ end
26
+
27
+ # Make a copy of the image.
28
+ #
29
+ # @return [Gosu::Image] Deep copy of the image.
30
+ def clone()
31
+ end
32
+
33
+ # (see #clone)
34
+ def dup()
35
+ end
36
+
37
+ # Iterate through every pixel of the image, allowing modification of each pixels.
38
+ #
39
+ # @yield [color, x, y] Colour and position (arity == 3).
40
+ # @yield [color] Colour only (arity == 1).
41
+ # @yieldparam [Array<Float>] color RGBA colour array. This can be modified to affect the image directly.
42
+ # @yieldparam [Integer] x X position of the pixel.
43
+ # @yieldparam [Integer] y Y position of the pixel.
44
+ def each(&block)
45
+ end
46
+
47
+ # Fill at a given position.
48
+ #
49
+ # @param [Number] x
50
+ # @param [Number] y
51
+ # @option options [Gosu::Color, Array<Float>, Symbol] :color (:white) Colour to apply to the drawing action.
52
+ # @option options [Proc, Hash] :color_control Effect to apply to the drawing action.
53
+ # @return [Gosu::Image]
54
+ def fill(x, y, options = {})
55
+ end
56
+
57
+ # Force synchronisation of the image (send from RAM to VRAM).
58
+ #
59
+ # @param [Array<Number>] rectangle Area to synchronise.
60
+ # @return [Gosu::Image]
61
+ def force_sync(rectangle = [0, 0, width, height])
62
+ end
63
+
64
+ # Get the colour of an individual pixel.
65
+ #
66
+ # @param [Number] x Horizontal position.
67
+ # @param [Number] y Vertical position.
68
+ # @return [Array<Float>] 4-element, RGBA colour array.
69
+ def get_pixel(x, y)
70
+ end
71
+
72
+ # @param [Number] x1 X position of start of line.
73
+ # @param [Number] y1 Y position of start of line.
74
+ # @param [Number] x2 X position of end of line.
75
+ # @param [Number] y2 Y position of end of line.
76
+ # @option (see #set_pixel)
77
+ # @option options [Number] :thickness (1) Thickness of the line.
78
+ # @option options [Hash] :trace Trace
79
+ # @return [Gosu::Image]
80
+ def line(x1, y1, x2, y2, options = {})
81
+ end
82
+
83
+ # Draw an n-sided polygon.
84
+ #
85
+ # @param (see #circle)
86
+ # @param [Integer] sides Number of sides for the polygon.
87
+ # @option (see #circle)
88
+ # @return [Gosu::Image]
89
+ def ngon(center_x, center_y, radius, sides, options = {})
90
+ end
91
+
92
+ # Offset all future drawing actions.
93
+ #
94
+ # The offset is non-stacking.
95
+ #
96
+ # Can also use +offset(:default)+ to reset offset to (0, 0).
97
+ #
98
+ # @param [Number] x
99
+ # @param [Number] y
100
+ # @return [Gosu::Image]
101
+ def offset(x, y)
102
+ end
103
+
104
+ # Perform drawing operations in the context of the image using _lazy_ syncing.
105
+ #
106
+ # The paint block may look like an ordinary instance_eval, but it is not. The problem that plagues the serious use of
107
+ # instance_eval: namely the inability to use local instance variables in the block does not affect the Paint Block.
108
+ # This means that code like the following is possible in TexPlay (but impossible with an instance_eval)
109
+ #
110
+ # How does it work? TexPlay uses an alternative to instance_eval known as gen_eval (http://github.com/banister/gen_eval/tree/master)
111
+ # Another peculiarity of paint blocks is how they sync the drawing actions (syncing will be discussed in greater depth
112
+ # later on). The drawing actions in a Paint Block are not sync�d until the very end of the Paint Block and are then
113
+ # sync'd to video memory all in one go (This style of syncing is called _lazy_ syncing in TexPlay)
114
+ #
115
+ # @example Drawing to the image within a paint block
116
+ # image1.paint do
117
+ # circle 10, 10, 20, :color => :green
118
+ # bezier [0, 0, 10, 10, 50, 0], :closed => true
119
+ # end
120
+ #
121
+ # @example Showing gen_eval behaviour (can access ivars within the paint block)
122
+ # @x = 20
123
+ # @y = 30
124
+ # my_image.paint do
125
+ # circle @x, @y, 20
126
+ # end
127
+ #
128
+ # @option options [Symbol] :sync_mode (:lazy_sync) One of +:lazy_sync+, +:no_sync+ or +:eager_sync+
129
+ # @yield Block evaluated as the image.
130
+ # @return [Gosu::Image]
131
+ def paint(options = {}, &block)
132
+ end
133
+
134
+ # Draw a series of connected lines.
135
+ #
136
+ # @param [Array<Number, TPPoint>] points Series of points (either [x1, y1, x2, y2, ...] or [point1, point2]).
137
+ # @option (see #rect)
138
+ # @option options [Boolean] :closed Whether the last point is linked to the first.
139
+ # @return [Gosu::Image]
140
+ def polyline(points, options = {})
141
+ end
142
+
143
+ # Draw a rectangle.
144
+ #
145
+ # @param [Number] x1 Top of the rectangle.
146
+ # @param [Number] y1 Left of the rectangle.
147
+ # @param [Number] x2 Right of the rectangle.
148
+ # @param [Number] y2 Bottom of the rectangle.
149
+ # @option (see #circle)
150
+ # @option options [Number] :thickness (1) Thickness of the line.
151
+ # @return [Gosu::Image]
152
+ def rect(x1, y1, x2, y2, options = {})
153
+ end
154
+ alias_method :box, :rect
155
+
156
+ # Set the colour of an individual pixel.
157
+ #
158
+ # @param [Number] x
159
+ # @param [Number] y
160
+ # @option (see #fill)
161
+ # @option options [Boolean] :alpha_blend (false) Alpha-blend instead of overwrite.
162
+ # @option options [Gosu::Image] :texture Texture to use instead of a flat colour.
163
+ # @option options [Symbol] :mode (:copy) Drawing mode to use.
164
+ # @return [Gosu::Image]
165
+ def set_pixel(x, y, options = {})
166
+ end
167
+ alias_method :pixel, :set_pixel
168
+
169
+ # Copy an image into another image.
170
+ #
171
+ # @param [Number] x Horizontal position to splice at.
172
+ # @param [Number] y Vertical position to splice at.
173
+ # @param [Gosu::Image] source Image to copy from.
174
+ # @option options [Gosu::Color, Array<Float>, Symbol] :chroma_key Colour to treat as transparent (only other colour pixels will be spliced).
175
+ # @option options [Gosu::Color, Array<Float>, Symbol] :chroma_key_not Colour to copy (other colours won't be spliced).
176
+ # @option options [Array<Float>] :crop ([0, 0, source.width - 1, source.height - 1]) Area of the source image to splice.
177
+ # @return [Gosu::Image]
178
+ def splice(x, y, source, options = {})
179
+ end
180
+ alias_method :composite, :splice
181
+
182
+ # Generate binary data from the image.
183
+ #
184
+ # @note This method is usually overridden by the default Gosu::Image#to_blob.
185
+ # @note This method causes a segmentation fault in Windows.
186
+ # @return [String] Raw binary data (blob) in RGBA byte order.
187
+ def to_blob
188
+ end
189
+ end
@@ -1,3 +1,3 @@
1
1
  module TexPlay
2
- VERSION = "0.2.983pre2"
2
+ VERSION = "0.3.0"
3
3
  end
metadata CHANGED
@@ -1,13 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: texplay
3
3
  version: !ruby/object:Gem::Version
4
- hash: 570791623
5
- prerelease: true
4
+ prerelease: false
6
5
  segments:
7
6
  - 0
8
- - 2
9
- - 983pre2
10
- version: 0.2.983pre2
7
+ - 3
8
+ - 0
9
+ version: 0.3.0
11
10
  platform: ruby
12
11
  authors:
13
12
  - John Mair (banisterfiend)
@@ -15,7 +14,7 @@ autorequire:
15
14
  bindir: bin
16
15
  cert_chain: []
17
16
 
18
- date: 2010-10-01 00:00:00 +13:00
17
+ date: 2010-11-01 00:00:00 +13:00
19
18
  default_executable:
20
19
  dependencies:
21
20
  - !ruby/object:Gem::Dependency
@@ -26,7 +25,6 @@ dependencies:
26
25
  requirements:
27
26
  - - ">="
28
27
  - !ruby/object:Gem::Version
29
- hash: 43
30
28
  segments:
31
29
  - 0
32
30
  - 7
@@ -46,10 +44,10 @@ files:
46
44
  - Rakefile
47
45
  - README.markdown
48
46
  - CHANGELOG
49
- - lib/texplay.rb
50
- - lib/texplay-contrib.rb
47
+ - lib/texplay/c_function_docs.rb
51
48
  - lib/texplay/version.rb
52
- - lib/texplay/patches.rb
49
+ - lib/texplay-contrib.rb
50
+ - lib/texplay.rb
53
51
  - ext/texplay/extconf.rb
54
52
  - ext/texplay/actions.h
55
53
  - ext/texplay/bindings.h
@@ -106,8 +104,8 @@ files:
106
104
  - examples/example_transparent3.rb
107
105
  - examples/example_turtle.rb
108
106
  - examples/example_weird.rb
107
+ - examples/example_window_render_to_image.rb
109
108
  - examples/example_window_to_blob.rb
110
- - examples/example_window_to_texture.rb
111
109
  - examples/media/bird.png
112
110
  - examples/media/body.png
113
111
  - examples/media/empty2.png
@@ -124,7 +122,7 @@ files:
124
122
  - examples/media/texplay.png
125
123
  - spec/image_spec.rb
126
124
  - spec/texplay_spec.rb
127
- has_rdoc: false
125
+ has_rdoc: yard
128
126
  homepage: http://banisterfiend.wordpress.com/2008/08/23/texplay-an-image-manipulation-tool-for-ruby-and-gosu/
129
127
  licenses: []
130
128
 
@@ -138,21 +136,17 @@ required_ruby_version: !ruby/object:Gem::Requirement
138
136
  requirements:
139
137
  - - ">="
140
138
  - !ruby/object:Gem::Version
141
- hash: 3
142
139
  segments:
143
140
  - 0
144
141
  version: "0"
145
142
  required_rubygems_version: !ruby/object:Gem::Requirement
146
143
  none: false
147
144
  requirements:
148
- - - ">"
145
+ - - ">="
149
146
  - !ruby/object:Gem::Version
150
- hash: 25
151
147
  segments:
152
- - 1
153
- - 3
154
- - 1
155
- version: 1.3.1
148
+ - 0
149
+ version: "0"
156
150
  requirements: []
157
151
 
158
152
  rubyforge_project:
@@ -1,55 +0,0 @@
1
- require 'common'
2
- require 'gosu'
3
- require 'texplay'
4
-
5
-
6
- class W < Gosu::Window
7
-
8
- def render_to_texture(image, x, y)
9
- tex_name = image.gl_tex_info.tex_name
10
- xoffset = image.gl_tex_info.left * Gosu::MAX_TEXTURE_SIZE * Gosu::MAX_TEXTURE_SIZE
11
- yoffset = image.gl_tex_info.top * Gosu::MAX_TEXTURE_SIZE
12
- width = image.width
13
- height = image.height
14
-
15
- self.to_texture(tex_name, xoffset, yoffset, x, y, width, height)
16
- end
17
-
18
- def initialize
19
- super(500, 500, false, 20)
20
- @img = Gosu::Image.new(self, "#{Common::MEDIA}/maria.png")
21
- @img2 = TexPlay.create_image(self, 100, 100, :color => Gosu::Color::RED)
22
-
23
- end
24
-
25
- def update
26
-
27
- end
28
-
29
- def draw
30
- @img.draw 0, 0,1
31
- @img2.draw rand(100), rand(100),1
32
- @img3.draw rand(300), rand(300), 1 if @img3
33
-
34
- if button_down?(Gosu::KbEscape)
35
- # self.flush
36
- @img3 = TexPlay.create_image(self, Gosu::MAX_TEXTURE_SIZE - 2, Gosu::MAX_TEXTURE_SIZE - 2, :color => :purple)
37
-
38
- render_to_texture(@img2, 0, self.height)
39
-
40
-
41
-
42
- # if @blob
43
- # @img3 = TexPlay.from_blob(self, @blob,50, 50 )
44
- # end
45
- end
46
-
47
- 500000.times {}
48
- end
49
-
50
- end
51
-
52
-
53
- w = W.new
54
- w.show
55
-
@@ -1,4 +0,0 @@
1
- # 1.9.2 path fix
2
-
3
- $LOAD_PATH.push File.dirname(File.expand_path(__FILE__))
4
-