sfml3-rb 0.2.2 → 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 (137) hide show
  1. checksums.yaml +4 -4
  2. data/.yardopts +9 -0
  3. data/CHANGELOG.md +43 -17
  4. data/README.md +97 -29
  5. data/ext/audio/audio_enums.c +58 -20
  6. data/ext/audio/listener.c +89 -6
  7. data/ext/audio/music.c +206 -5
  8. data/ext/audio/sound.c +175 -5
  9. data/ext/audio/sound_buffer.c +189 -47
  10. data/ext/audio/sound_buffer_recorder.c +83 -16
  11. data/ext/audio/sound_recorder.c +172 -52
  12. data/ext/audio/sound_source_cone.c +108 -29
  13. data/ext/audio/sound_stream.c +178 -5
  14. data/ext/core/exceptions.c +10 -8
  15. data/ext/core/unicode.c +12 -2
  16. data/ext/ext.c +4 -0
  17. data/ext/graphics/blend_mode.c +203 -53
  18. data/ext/graphics/circle.c +271 -4
  19. data/ext/graphics/color.c +240 -90
  20. data/ext/graphics/drawable.c +15 -4
  21. data/ext/graphics/font.c +138 -25
  22. data/ext/graphics/glyph.c +31 -8
  23. data/ext/graphics/image.c +180 -37
  24. data/ext/graphics/polygon.c +293 -26
  25. data/ext/graphics/rect.c +211 -54
  26. data/ext/graphics/rectangle.c +279 -26
  27. data/ext/graphics/render_state.c +116 -2
  28. data/ext/graphics/render_texture.c +163 -2
  29. data/ext/graphics/shader.c +283 -17
  30. data/ext/graphics/shape.c +252 -26
  31. data/ext/graphics/sprite.c +216 -25
  32. data/ext/graphics/stencil_mode.c +148 -39
  33. data/ext/graphics/target.c +67 -22
  34. data/ext/graphics/target.h +15 -15
  35. data/ext/graphics/text.c +306 -6
  36. data/ext/graphics/texture.c +257 -3
  37. data/ext/graphics/transform.c +178 -5
  38. data/ext/graphics/transformable.c +126 -2
  39. data/ext/graphics/vertex.c +79 -2
  40. data/ext/graphics/vertex_array.c +128 -16
  41. data/ext/graphics/vertex_buffer.c +124 -2
  42. data/ext/graphics/view.c +130 -2
  43. data/ext/network/ftp.c +249 -10
  44. data/ext/network/http.c +156 -38
  45. data/ext/network/ip_address.c +107 -26
  46. data/ext/network/network_enums.c +248 -141
  47. data/ext/network/packet.c +273 -39
  48. data/ext/network/socket_selector.c +91 -19
  49. data/ext/network/tcp_listener.c +75 -16
  50. data/ext/network/tcp_socket.c +128 -25
  51. data/ext/network/udp_socket.c +122 -26
  52. data/ext/ports.rb +7 -0
  53. data/ext/system/buffer.c +41 -12
  54. data/ext/system/clock.c +68 -9
  55. data/ext/system/input_stream.c +94 -42
  56. data/ext/system/sleep.c +10 -2
  57. data/ext/system/time.c +172 -34
  58. data/ext/system/vec2.c +156 -35
  59. data/ext/system/vec3.c +166 -35
  60. data/ext/window/clipboard.c +47 -17
  61. data/ext/window/context.c +59 -9
  62. data/ext/window/context_settings.c +116 -38
  63. data/ext/window/cursor.c +39 -9
  64. data/ext/window/event.c +163 -42
  65. data/ext/window/joystick.c +69 -3
  66. data/ext/window/keyboard.c +168 -116
  67. data/ext/window/mouse.c +36 -2
  68. data/ext/window/sensor.c +28 -2
  69. data/ext/window/touch.c +20 -2
  70. data/ext/window/video_mode.c +90 -19
  71. data/ext/window/vulkan.c +34 -6
  72. data/ext/window/window.c +340 -16
  73. data/lib/sfml/version.rb +1 -1
  74. data/sig/audio/audio_enums.rbs +30 -0
  75. data/sig/audio/listener.rbs +16 -0
  76. data/sig/audio/music.rbs +56 -0
  77. data/sig/audio/sound.rbs +51 -0
  78. data/sig/audio/sound_buffer.rbs +17 -0
  79. data/sig/audio/sound_buffer_recorder.rbs +14 -0
  80. data/sig/audio/sound_recorder.rbs +17 -0
  81. data/sig/audio/sound_source_cone.rbs +14 -0
  82. data/sig/audio/sound_stream.rbs +51 -0
  83. data/sig/graphics/blend_mode.rbs +29 -0
  84. data/sig/graphics/circle.rbs +44 -0
  85. data/sig/graphics/color.rbs +39 -0
  86. data/sig/graphics/drawable.rbs +5 -0
  87. data/sig/graphics/font.rbs +20 -0
  88. data/sig/graphics/glyph.rbs +7 -0
  89. data/sig/graphics/image.rbs +22 -0
  90. data/sig/graphics/polygon.rbs +42 -0
  91. data/sig/graphics/rect.rbs +33 -0
  92. data/sig/graphics/rectangle.rbs +42 -0
  93. data/sig/graphics/render_state.rbs +21 -0
  94. data/sig/graphics/render_texture.rbs +37 -0
  95. data/sig/graphics/shader.rbs +39 -0
  96. data/sig/graphics/shape.rbs +38 -0
  97. data/sig/graphics/sprite.rbs +34 -0
  98. data/sig/graphics/stencil_mode.rbs +18 -0
  99. data/sig/graphics/target.rbs +10 -0
  100. data/sig/graphics/text.rbs +48 -0
  101. data/sig/graphics/texture.rbs +34 -0
  102. data/sig/graphics/transform.rbs +37 -0
  103. data/sig/graphics/transformable.rbs +25 -0
  104. data/sig/graphics/vertex.rbs +17 -0
  105. data/sig/graphics/vertex_array.rbs +17 -0
  106. data/sig/graphics/vertex_buffer.rbs +22 -0
  107. data/sig/graphics/view.rbs +24 -0
  108. data/sig/network/ftp.rbs +46 -0
  109. data/sig/network/http.rbs +27 -0
  110. data/sig/network/ip_address.rbs +22 -0
  111. data/sig/network/network_enums.rbs +95 -0
  112. data/sig/network/packet.rbs +40 -0
  113. data/sig/network/socket_selector.rbs +14 -0
  114. data/sig/network/tcp_listener.rbs +13 -0
  115. data/sig/network/tcp_socket.rbs +18 -0
  116. data/sig/network/udp_socket.rbs +17 -0
  117. data/sig/system/buffer.rbs +11 -0
  118. data/sig/system/clock.rbs +13 -0
  119. data/sig/system/input_stream.rbs +7 -0
  120. data/sig/system/sleep.rbs +3 -0
  121. data/sig/system/time.rbs +28 -0
  122. data/sig/system/vec2.rbs +26 -0
  123. data/sig/system/vec3.rbs +27 -0
  124. data/sig/window/clipboard.rbs +8 -0
  125. data/sig/window/context.rbs +11 -0
  126. data/sig/window/context_settings.rbs +20 -0
  127. data/sig/window/cursor.rbs +6 -0
  128. data/sig/window/event.rbs +20 -0
  129. data/sig/window/joystick.rbs +15 -0
  130. data/sig/window/keyboard.rbs +10 -0
  131. data/sig/window/mouse.rbs +9 -0
  132. data/sig/window/sensor.rbs +8 -0
  133. data/sig/window/touch.rbs +6 -0
  134. data/sig/window/video_mode.rbs +16 -0
  135. data/sig/window/vulkan.rbs +7 -0
  136. data/sig/window/window.rbs +57 -0
  137. metadata +66 -2
@@ -16,39 +16,38 @@
16
16
  #include "core/macros.h"
17
17
 
18
18
  typedef struct {
19
- sfRectangleShape *shape;
19
+ sfRectangleShape* shape;
20
20
  VALUE rb_texture;
21
21
  } RectangleShape;
22
22
 
23
23
  static VALUE rb_cRectangleShape;
24
24
 
25
- static void RectangleShape_mark(void *ptr) {
26
- rb_gc_mark(((RectangleShape *) ptr)->rb_texture);
25
+ static void RectangleShape_mark(void* ptr) {
26
+ rb_gc_mark(((RectangleShape*)ptr)->rb_texture);
27
27
  }
28
28
 
29
- static void RectangleShape_free(void *ptr) {
30
- sfRectangleShape_destroy(((RectangleShape *) ptr)->shape);
29
+ static void RectangleShape_free(void* ptr) {
30
+ sfRectangleShape_destroy(((RectangleShape*)ptr)->shape);
31
31
  free(ptr);
32
32
  }
33
33
 
34
34
  static const rb_data_type_t RectangleShape_data_type = {
35
35
  .wrap_struct_name = "SFML::RectangleShape",
36
36
  .function = {.dmark = RectangleShape_mark, .dfree = RectangleShape_free, .dsize = NULL},
37
- .flags = RUBY_TYPED_FREE_IMMEDIATELY
38
- };
37
+ .flags = RUBY_TYPED_FREE_IMMEDIATELY};
39
38
 
40
- static RectangleShape *Get_RectangleShape(VALUE self) {
41
- RectangleShape *ptr;
39
+ static RectangleShape* Get_RectangleShape(VALUE self) {
40
+ RectangleShape* ptr;
42
41
  TypedData_Get_Struct(self, RectangleShape, &RectangleShape_data_type, ptr);
43
42
  return ptr;
44
43
  }
45
44
 
46
- static sfRectangleShape *Get_RectangleShape_Struct(VALUE self) {
45
+ static sfRectangleShape* Get_RectangleShape_Struct(VALUE self) {
47
46
  return Get_RectangleShape(self)->shape;
48
47
  }
49
48
 
50
- static VALUE RectangleShape_wrap(VALUE klass, sfRectangleShape *shape) {
51
- RectangleShape *ptr;
49
+ static VALUE RectangleShape_wrap(VALUE klass, sfRectangleShape* shape) {
50
+ RectangleShape* ptr;
52
51
 
53
52
  if (shape == NULL) {
54
53
  rb_raise(rb_eRuntimeError, "failed to create rectangle shape");
@@ -61,8 +60,15 @@ static VALUE RectangleShape_wrap(VALUE klass, sfRectangleShape *shape) {
61
60
  return TypedData_Wrap_Struct(klass, &RectangleShape_data_type, ptr);
62
61
  }
63
62
 
64
- static VALUE RectangleShape_new(int argc, VALUE *argv, VALUE klass) {
65
- sfRectangleShape *shape = sfRectangleShape_create();
63
+ /* call-seq:
64
+ * RectangleShape.new(size = Vector2.new(0, 0)) -> RectangleShape
65
+ *
66
+ * Creates a rectangle shape with the given +size+.
67
+ *
68
+ * @return [RectangleShape]
69
+ */
70
+ static VALUE RectangleShape_new(int argc, VALUE* argv, VALUE klass) {
71
+ sfRectangleShape* shape = sfRectangleShape_create();
66
72
  VALUE rb_size;
67
73
 
68
74
  rb_scan_args(argc, argv, "01", &rb_size);
@@ -74,12 +80,19 @@ static VALUE RectangleShape_new(int argc, VALUE *argv, VALUE klass) {
74
80
  return RectangleShape_wrap(klass, shape);
75
81
  }
76
82
 
83
+ /* call-seq: copy -> RectangleShape
84
+ *
85
+ * Returns a deep copy of the object.
86
+ *
87
+ * @return [RectangleShape] an independent copy, including its texture
88
+ * reference
89
+ */
77
90
  static VALUE RectangleShape_copy(VALUE self) {
78
- RectangleShape *ptr = Get_RectangleShape(self);
91
+ RectangleShape* ptr = Get_RectangleShape(self);
79
92
  VALUE copy = RectangleShape_wrap(Get_Klass_RectangleShape(), sfRectangleShape_copy(ptr->shape));
80
93
 
81
94
  if (!NIL_P(ptr->rb_texture)) {
82
- RectangleShape *copy_ptr = Get_RectangleShape(copy);
95
+ RectangleShape* copy_ptr = Get_RectangleShape(copy);
83
96
 
84
97
  copy_ptr->rb_texture = ptr->rb_texture;
85
98
  sfRectangleShape_setTexture(copy_ptr->shape, Get_Texture_Struct(ptr->rb_texture), false);
@@ -88,103 +101,247 @@ static VALUE RectangleShape_copy(VALUE self) {
88
101
  return copy;
89
102
  }
90
103
 
104
+ /* call-seq: size -> Vector2
105
+ *
106
+ * Returns the object's size.
107
+ *
108
+ * @return [Vector2]
109
+ */
91
110
  static VALUE RectangleShape_get_size(VALUE self) {
92
111
  return vec2f_to_rb(sfRectangleShape_getSize(Get_RectangleShape_Struct(self)));
93
112
  }
94
113
 
114
+ /* call-seq:
115
+ * size=(value) -> Vector2
116
+ *
117
+ * Sets the object's size.
118
+ *
119
+ * @return [Vector2] +value+
120
+ */
95
121
  static VALUE RectangleShape_set_size(VALUE self, VALUE rb_size) {
96
122
  sfRectangleShape_setSize(Get_RectangleShape_Struct(self), vec2f_from_rb(rb_size));
97
123
  return rb_size;
98
124
  }
99
125
 
126
+ /* call-seq: position -> Vector2
127
+ *
128
+ * Returns the object's position.
129
+ *
130
+ * @return [Vector2]
131
+ */
100
132
  static VALUE RectangleShape_get_position(VALUE self) {
101
133
  return vec2f_to_rb(sfRectangleShape_getPosition(Get_RectangleShape_Struct(self)));
102
134
  }
103
135
 
136
+ /* call-seq:
137
+ * position=(value) -> Vector2
138
+ *
139
+ * Sets the object's position.
140
+ *
141
+ * @return [Vector2] +value+
142
+ */
104
143
  static VALUE RectangleShape_set_position(VALUE self, VALUE rb_position) {
105
144
  sfRectangleShape_setPosition(Get_RectangleShape_Struct(self), vec2f_from_rb(rb_position));
106
145
  return rb_position;
107
146
  }
108
147
 
148
+ /* call-seq: rotation -> Float
149
+ *
150
+ * Returns the object's rotation, in degrees.
151
+ *
152
+ * @return [Float]
153
+ */
109
154
  static VALUE RectangleShape_get_rotation(VALUE self) {
110
155
  return DBL2NUM(sfRectangleShape_getRotation(Get_RectangleShape_Struct(self)));
111
156
  }
112
157
 
158
+ /* call-seq:
159
+ * rotation=(value) -> Float
160
+ *
161
+ * Sets the object's rotation, in degrees.
162
+ *
163
+ * @return [Float] +value+
164
+ */
113
165
  static VALUE RectangleShape_set_rotation(VALUE self, VALUE rb_rotation) {
114
166
  sfRectangleShape_setRotation(Get_RectangleShape_Struct(self), NUM2DBL(rb_rotation));
115
167
  return rb_rotation;
116
168
  }
117
169
 
170
+ /* call-seq: scale -> Vector2
171
+ *
172
+ * Returns the object's scale factors.
173
+ *
174
+ * @return [Vector2]
175
+ */
118
176
  static VALUE RectangleShape_get_scale(VALUE self) {
119
177
  return vec2f_to_rb(sfRectangleShape_getScale(Get_RectangleShape_Struct(self)));
120
178
  }
121
179
 
180
+ /* call-seq:
181
+ * scale=(value) -> Vector2
182
+ *
183
+ * Sets the object's scale factors.
184
+ *
185
+ * @return [Vector2] +value+
186
+ */
122
187
  static VALUE RectangleShape_set_scale(VALUE self, VALUE rb_scale) {
123
188
  sfRectangleShape_setScale(Get_RectangleShape_Struct(self), vec2f_from_rb(rb_scale));
124
189
  return rb_scale;
125
190
  }
126
191
 
192
+ /* call-seq: origin -> Vector2
193
+ *
194
+ * Returns the object's origin.
195
+ *
196
+ * @return [Vector2]
197
+ */
127
198
  static VALUE RectangleShape_get_origin(VALUE self) {
128
199
  return vec2f_to_rb(sfRectangleShape_getOrigin(Get_RectangleShape_Struct(self)));
129
200
  }
130
201
 
202
+ /* call-seq:
203
+ * origin=(value) -> Vector2
204
+ *
205
+ * Sets the object's origin.
206
+ *
207
+ * @return [Vector2] +value+
208
+ */
131
209
  static VALUE RectangleShape_set_origin(VALUE self, VALUE rb_origin) {
132
210
  sfRectangleShape_setOrigin(Get_RectangleShape_Struct(self), vec2f_from_rb(rb_origin));
133
211
  return rb_origin;
134
212
  }
135
213
 
214
+ /* call-seq: move(offset) -> self
215
+ *
216
+ * Moves the object by +offset+.
217
+ *
218
+ * @return [self]
219
+ */
136
220
  static VALUE RectangleShape_move(VALUE self, VALUE rb_offset) {
137
221
  sfRectangleShape_move(Get_RectangleShape_Struct(self), vec2f_from_rb(rb_offset));
138
222
  return self;
139
223
  }
140
224
 
225
+ /* call-seq: rotate(angle) -> self
226
+ *
227
+ * Rotates the object by +angle+ degrees.
228
+ *
229
+ * @return [self]
230
+ */
141
231
  static VALUE RectangleShape_rotate(VALUE self, VALUE rb_angle) {
142
232
  sfRectangleShape_rotate(Get_RectangleShape_Struct(self), NUM2DBL(rb_angle));
143
233
  return self;
144
234
  }
145
235
 
236
+ /* call-seq:
237
+ * scale!(factors) -> self
238
+ *
239
+ * Scales the object by +factors+ relative to its current scale.
240
+ *
241
+ * @return [self]
242
+ */
146
243
  static VALUE RectangleShape_scale(VALUE self, VALUE rb_factors) {
147
244
  sfRectangleShape_scale(Get_RectangleShape_Struct(self), vec2f_from_rb(rb_factors));
148
245
  return self;
149
246
  }
150
247
 
248
+ /* call-seq: transform -> Array
249
+ *
250
+ * Also available as #matrix.
251
+ *
252
+ * @return [Array] the 3x3 row-major transform matrix
253
+ */
151
254
  static VALUE RectangleShape_get_transform(VALUE self) {
152
- return Transform_MatrixToArray(sfRectangleShape_getTransform(Get_RectangleShape_Struct(self)).matrix);
255
+ return Transform_MatrixToArray(
256
+ sfRectangleShape_getTransform(Get_RectangleShape_Struct(self)).matrix);
153
257
  }
154
258
 
259
+ /* call-seq: inverse_transform -> Array
260
+ *
261
+ * Returns the 3x3 row-major inverse of the object's transform matrix.
262
+ *
263
+ * @return [Array] the 3x3 row-major inverse transform matrix
264
+ */
155
265
  static VALUE RectangleShape_get_inverse_transform(VALUE self) {
156
- return Transform_MatrixToArray(sfRectangleShape_getInverseTransform(Get_RectangleShape_Struct(self)).matrix);
266
+ return Transform_MatrixToArray(
267
+ sfRectangleShape_getInverseTransform(Get_RectangleShape_Struct(self)).matrix);
157
268
  }
158
269
 
270
+ /* call-seq: fill_color -> Color
271
+ *
272
+ * Returns the shape's fill color.
273
+ *
274
+ * @return [Color]
275
+ */
159
276
  static VALUE RectangleShape_get_fill_color(VALUE self) {
160
277
  return color_to_rb(sfRectangleShape_getFillColor(Get_RectangleShape_Struct(self)));
161
278
  }
162
279
 
280
+ /* call-seq:
281
+ * fill_color=(value) -> Color
282
+ *
283
+ * Sets the shape's fill color.
284
+ *
285
+ * @return [Color] +value+
286
+ */
163
287
  static VALUE RectangleShape_set_fill_color(VALUE self, VALUE rb_color) {
164
288
  sfRectangleShape_setFillColor(Get_RectangleShape_Struct(self), color_from_rb(rb_color));
165
289
  return rb_color;
166
290
  }
167
291
 
292
+ /* call-seq: outline_color -> Color
293
+ *
294
+ * Returns the shape's outline color.
295
+ *
296
+ * @return [Color]
297
+ */
168
298
  static VALUE RectangleShape_get_outline_color(VALUE self) {
169
299
  return color_to_rb(sfRectangleShape_getOutlineColor(Get_RectangleShape_Struct(self)));
170
300
  }
171
301
 
302
+ /* call-seq:
303
+ * outline_color=(value) -> Color
304
+ *
305
+ * Sets the shape's outline color.
306
+ *
307
+ * @return [Color] +value+
308
+ */
172
309
  static VALUE RectangleShape_set_outline_color(VALUE self, VALUE rb_color) {
173
310
  sfRectangleShape_setOutlineColor(Get_RectangleShape_Struct(self), color_from_rb(rb_color));
174
311
  return rb_color;
175
312
  }
176
313
 
314
+ /* call-seq: outline_thickness -> Float
315
+ *
316
+ * Returns the shape's outline thickness.
317
+ *
318
+ * @return [Float]
319
+ */
177
320
  static VALUE RectangleShape_get_outline_thickness(VALUE self) {
178
321
  return DBL2NUM(sfRectangleShape_getOutlineThickness(Get_RectangleShape_Struct(self)));
179
322
  }
180
323
 
324
+ /* call-seq:
325
+ * outline_thickness=(value) -> Float
326
+ *
327
+ * Sets the shape's outline thickness.
328
+ *
329
+ * @return [Float] +value+
330
+ */
181
331
  static VALUE RectangleShape_set_outline_thickness(VALUE self, VALUE rb_thickness) {
182
332
  sfRectangleShape_setOutlineThickness(Get_RectangleShape_Struct(self), NUM2DBL(rb_thickness));
183
333
  return rb_thickness;
184
334
  }
185
335
 
336
+ /* call-seq:
337
+ * texture=(value) -> Texture or nil
338
+ *
339
+ * Sets the object's texture.
340
+ *
341
+ * @return [Texture, nil] +value+
342
+ */
186
343
  static VALUE RectangleShape_set_texture(VALUE self, VALUE rb_texture) {
187
- RectangleShape *ptr = Get_RectangleShape(self);
344
+ RectangleShape* ptr = Get_RectangleShape(self);
188
345
  bool reset_rect = false;
189
346
 
190
347
  if (NIL_P(rb_texture)) {
@@ -203,39 +360,96 @@ static VALUE RectangleShape_set_texture(VALUE self, VALUE rb_texture) {
203
360
  return rb_texture;
204
361
  }
205
362
 
363
+ /* call-seq: texture -> Texture or nil
364
+ *
365
+ * Returns the object's texture, or +nil+ if it has none.
366
+ *
367
+ * @return [Texture, nil]
368
+ */
206
369
  static VALUE RectangleShape_get_texture(VALUE self) {
207
370
  return Get_RectangleShape(self)->rb_texture;
208
371
  }
209
372
 
373
+ /* call-seq: texture_rect -> Rect
374
+ *
375
+ * Returns the sub-rectangle of the texture displayed on the object.
376
+ *
377
+ * @return [Rect] the sub-rectangle of the texture displayed on the rectangle
378
+ */
210
379
  static VALUE RectangleShape_get_texture_rect(VALUE self) {
211
380
  return int_rect_to_rb(sfRectangleShape_getTextureRect(Get_RectangleShape_Struct(self)));
212
381
  }
213
382
 
383
+ /* call-seq:
384
+ * texture_rect=(value) -> Rect
385
+ *
386
+ * Sets the sub-rectangle of the texture displayed on the object.
387
+ *
388
+ * @return [Rect] +value+
389
+ */
214
390
  static VALUE RectangleShape_set_texture_rect(VALUE self, VALUE rb_rect) {
215
391
  sfRectangleShape_setTextureRect(Get_RectangleShape_Struct(self), int_rect_from_rb(rb_rect));
216
392
  return rb_rect;
217
393
  }
218
394
 
395
+ /* call-seq: point_count -> Integer
396
+ *
397
+ * Returns the number of points composing the shape.
398
+ *
399
+ * @return [Integer] always 4
400
+ */
219
401
  static VALUE RectangleShape_get_point_count(VALUE self) {
220
402
  return SIZET2NUM(sfRectangleShape_getPointCount(Get_RectangleShape_Struct(self)));
221
403
  }
222
404
 
405
+ /* call-seq: point(index) -> Vector2
406
+ *
407
+ * Returns the local position of the point at +index+.
408
+ *
409
+ * @return [Vector2] the local position of the corner at +index+
410
+ */
223
411
  static VALUE RectangleShape_get_point(VALUE self, VALUE rb_index) {
224
- return vec2f_to_rb(sfRectangleShape_getPoint(Get_RectangleShape_Struct(self), (size_t) NUM2SIZET(rb_index)));
412
+ return vec2f_to_rb(
413
+ sfRectangleShape_getPoint(Get_RectangleShape_Struct(self), (size_t)NUM2SIZET(rb_index)));
225
414
  }
226
415
 
416
+ /* call-seq: geometric_center -> Vector2
417
+ *
418
+ * Returns the local position of the shape's geometric center.
419
+ *
420
+ * @return [Vector2] the local position of the shape's geometric center
421
+ */
227
422
  static VALUE RectangleShape_get_geometric_center(VALUE self) {
228
423
  return vec2f_to_rb(sfRectangleShape_getGeometricCenter(Get_RectangleShape_Struct(self)));
229
424
  }
230
425
 
426
+ /* call-seq: local_bounds -> Rect
427
+ *
428
+ * Returns the bounding box in local (untransformed) coordinates.
429
+ *
430
+ * @return [Rect] the bounding box in local (untransformed) coordinates
431
+ */
231
432
  static VALUE RectangleShape_get_local_bounds(VALUE self) {
232
433
  return rect_to_rb(sfRectangleShape_getLocalBounds(Get_RectangleShape_Struct(self)));
233
434
  }
234
435
 
436
+ /* call-seq: global_bounds -> Rect
437
+ *
438
+ * Returns the bounding box after the transform is applied.
439
+ *
440
+ * @return [Rect] the bounding box after transform is applied
441
+ */
235
442
  static VALUE RectangleShape_get_global_bounds(VALUE self) {
236
443
  return rect_to_rb(sfRectangleShape_getGlobalBounds(Get_RectangleShape_Struct(self)));
237
444
  }
238
445
 
446
+ /* call-seq:
447
+ * draw(target, state) -> nil
448
+ *
449
+ * Draws the object onto +target+ using the given render +state+.
450
+ *
451
+ * @return [nil]
452
+ */
239
453
  static VALUE RectangleShape_draw(VALUE self, VALUE rb_target, VALUE rb_state) {
240
454
  if (!rb_obj_is_kind_of(rb_target, Get_Klass_Target())) {
241
455
  raise_invalid_argument_class(Get_Klass_Target());
@@ -252,8 +466,43 @@ static VALUE RectangleShape_draw(VALUE self, VALUE rb_target, VALUE rb_state) {
252
466
  return Qnil;
253
467
  }
254
468
 
255
- void Init_RectangleShape(VALUE rb_module) {
256
- rb_cRectangleShape = rb_define_class_under(rb_module, "RectangleShape", rb_cObject);
469
+ /* Document-class: SFML::RectangleShape
470
+ * A rectangle shape, drawable, transformable and stylable like the other
471
+ * SFML shapes. Includes Drawable.
472
+ *
473
+ * @!attribute size
474
+ * The object's size.
475
+ * @return [Vector2]
476
+ * @!attribute position
477
+ * The object's position.
478
+ * @return [Vector2]
479
+ * @!attribute rotation
480
+ * The object's rotation, in degrees.
481
+ * @return [Float]
482
+ * @!attribute scale
483
+ * The object's scale factors.
484
+ * @return [Vector2]
485
+ * @!attribute origin
486
+ * The object's origin.
487
+ * @return [Vector2]
488
+ * @!attribute fill_color
489
+ * The object's fill color.
490
+ * @return [Color]
491
+ * @!attribute outline_color
492
+ * The object's outline color.
493
+ * @return [Color]
494
+ * @!attribute outline_thickness
495
+ * The object's outline thickness.
496
+ * @return [Float]
497
+ * @!attribute texture
498
+ * The object's texture, or +nil+ if it has none.
499
+ * @return [Texture, nil]
500
+ * @!attribute texture_rect
501
+ * The sub-rectangle of the texture displayed on the object.
502
+ * @return [Rect]
503
+ */
504
+ void Init_RectangleShape(VALUE rb_mSFML) {
505
+ rb_cRectangleShape = rb_define_class_under(rb_mSFML, "RectangleShape", rb_cObject);
257
506
 
258
507
  rb_include_module(rb_cRectangleShape, Get_Module_Drawable());
259
508
 
@@ -268,16 +517,19 @@ void Init_RectangleShape(VALUE rb_module) {
268
517
  rb_define_method(rb_cRectangleShape, "origin", RectangleShape_get_origin, 0);
269
518
  rb_define_method(rb_cRectangleShape, "fill_color", RectangleShape_get_fill_color, 0);
270
519
  rb_define_method(rb_cRectangleShape, "outline_color", RectangleShape_get_outline_color, 0);
271
- rb_define_method(rb_cRectangleShape, "outline_thickness", RectangleShape_get_outline_thickness, 0);
520
+ rb_define_method(rb_cRectangleShape, "outline_thickness", RectangleShape_get_outline_thickness,
521
+ 0);
272
522
  rb_define_method(rb_cRectangleShape, "texture", RectangleShape_get_texture, 0);
273
523
  rb_define_method(rb_cRectangleShape, "texture_rect", RectangleShape_get_texture_rect, 0);
274
524
  rb_define_method(rb_cRectangleShape, "point_count", RectangleShape_get_point_count, 0);
275
525
  rb_define_method(rb_cRectangleShape, "point", RectangleShape_get_point, 1);
276
- rb_define_method(rb_cRectangleShape, "geometric_center", RectangleShape_get_geometric_center, 0);
526
+ rb_define_method(rb_cRectangleShape, "geometric_center", RectangleShape_get_geometric_center,
527
+ 0);
277
528
  rb_define_method(rb_cRectangleShape, "local_bounds", RectangleShape_get_local_bounds, 0);
278
529
  rb_define_method(rb_cRectangleShape, "global_bounds", RectangleShape_get_global_bounds, 0);
279
530
  rb_define_method(rb_cRectangleShape, "transform", RectangleShape_get_transform, 0);
280
- rb_define_method(rb_cRectangleShape, "inverse_transform", RectangleShape_get_inverse_transform, 0);
531
+ rb_define_method(rb_cRectangleShape, "inverse_transform", RectangleShape_get_inverse_transform,
532
+ 0);
281
533
  rb_define_method(rb_cRectangleShape, "matrix", RectangleShape_get_transform, 0);
282
534
 
283
535
  rb_define_method(rb_cRectangleShape, "size=", RectangleShape_set_size, 1);
@@ -287,7 +539,8 @@ void Init_RectangleShape(VALUE rb_module) {
287
539
  rb_define_method(rb_cRectangleShape, "origin=", RectangleShape_set_origin, 1);
288
540
  rb_define_method(rb_cRectangleShape, "fill_color=", RectangleShape_set_fill_color, 1);
289
541
  rb_define_method(rb_cRectangleShape, "outline_color=", RectangleShape_set_outline_color, 1);
290
- rb_define_method(rb_cRectangleShape, "outline_thickness=", RectangleShape_set_outline_thickness, 1);
542
+ rb_define_method(rb_cRectangleShape, "outline_thickness=", RectangleShape_set_outline_thickness,
543
+ 1);
291
544
  rb_define_method(rb_cRectangleShape, "texture=", RectangleShape_set_texture, 1);
292
545
  rb_define_method(rb_cRectangleShape, "texture_rect=", RectangleShape_set_texture_rect, 1);
293
546
 
@@ -56,6 +56,17 @@ static VALUE RenderStates_wrap(VALUE klass, RenderStates* states) {
56
56
  return TypedData_Wrap_Struct(klass, &RenderStates_data_type, states);
57
57
  }
58
58
 
59
+ /* call-seq:
60
+ * RenderState.new -> RenderState
61
+ * RenderState.new(matrix) -> RenderState
62
+ *
63
+ * Creates a render state with SFML's default blend mode, stencil mode and
64
+ * coordinate type, and identity transform unless +matrix+ (a 3x3
65
+ * row-major Array, see Transform) is given.
66
+ *
67
+ * @return [RenderState]
68
+ * @raise [ArgumentError] if given more than one argument
69
+ */
59
70
  static VALUE RenderStates_new(int argc, VALUE* argv, VALUE klass) {
60
71
  RenderStates* states;
61
72
  VALUE self;
@@ -75,6 +86,14 @@ static VALUE RenderStates_new(int argc, VALUE* argv, VALUE klass) {
75
86
  return self;
76
87
  }
77
88
 
89
+ /* call-seq:
90
+ * transform=(matrix) -> self
91
+ * matrix=(matrix) -> self
92
+ *
93
+ * +matrix+ is a 3x3 row-major Array, see Transform.
94
+ *
95
+ * @return [self]
96
+ */
78
97
  static VALUE RenderStates_set_transform(VALUE self, VALUE rb_matrix) {
79
98
  sfRenderStates* states = Get_RenderState_Struct(self);
80
99
 
@@ -83,32 +102,77 @@ static VALUE RenderStates_set_transform(VALUE self, VALUE rb_matrix) {
83
102
  return self;
84
103
  }
85
104
 
105
+ /* call-seq: transform -> Array
106
+ *
107
+ * Also available as #matrix.
108
+ *
109
+ * @return [Array] the 3x3 row-major transform matrix
110
+ */
86
111
  static VALUE RenderStates_get_transform(VALUE self) {
87
112
  return Transform_MatrixToArray(Get_RenderState_Struct(self)->transform.matrix);
88
113
  }
89
114
 
115
+ /* call-seq: blend_mode -> BlendMode
116
+ *
117
+ * Returns the state's blend mode.
118
+ *
119
+ * @return [BlendMode]
120
+ */
90
121
  static VALUE RenderStates_get_blend_mode(VALUE self) {
91
122
  return blend_mode_to_rb(Get_RenderState_Struct(self)->blendMode);
92
123
  }
93
124
 
125
+ /* call-seq:
126
+ * blend_mode=(value) -> BlendMode
127
+ *
128
+ * Sets the state's blend mode.
129
+ *
130
+ * @return [BlendMode] +value+
131
+ */
94
132
  static VALUE RenderStates_set_blend_mode(VALUE self, VALUE rb_mode) {
95
133
  Get_RenderState_Struct(self)->blendMode = blend_mode_from_rb(rb_mode);
96
134
  return rb_mode;
97
135
  }
98
136
 
137
+ /* call-seq: stencil_mode -> StencilMode
138
+ *
139
+ * Returns the state's stencil mode.
140
+ *
141
+ * @return [StencilMode]
142
+ */
99
143
  static VALUE RenderStates_get_stencil_mode(VALUE self) {
100
144
  return stencil_mode_to_rb(Get_RenderState_Struct(self)->stencilMode);
101
145
  }
102
146
 
147
+ /* call-seq:
148
+ * stencil_mode=(value) -> StencilMode
149
+ *
150
+ * Sets the state's stencil mode.
151
+ *
152
+ * @return [StencilMode] +value+
153
+ */
103
154
  static VALUE RenderStates_set_stencil_mode(VALUE self, VALUE rb_mode) {
104
155
  Get_RenderState_Struct(self)->stencilMode = stencil_mode_from_rb(rb_mode);
105
156
  return rb_mode;
106
157
  }
107
158
 
159
+ /* call-seq: coordinate_type -> Symbol
160
+ *
161
+ * Returns the state's texture coordinate type.
162
+ *
163
+ * @return [Symbol] either +:pixels+ or +:normalized+
164
+ */
108
165
  static VALUE RenderStates_get_coordinate_type(VALUE self) {
109
166
  return ID2SYM(rb_intern(coordinate_type_name(Get_RenderState_Struct(self)->coordinateType)));
110
167
  }
111
168
 
169
+ /* call-seq:
170
+ * coordinate_type=(value) -> Symbol
171
+ *
172
+ * +value+ is +:pixels+ or +:normalized+.
173
+ *
174
+ * @return [Symbol] +value+
175
+ */
112
176
  static VALUE RenderStates_set_coordinate_type(VALUE self, VALUE rb_type) {
113
177
  Get_RenderState_Struct(self)->coordinateType = coordinate_type_from_rb(rb_type);
114
178
  return rb_type;
@@ -119,10 +183,23 @@ static RenderStates* Get_RenderStates_Wrapper(VALUE self) {
119
183
  return (RenderStates*)Get_RenderState_Struct(self);
120
184
  }
121
185
 
186
+ /* call-seq: texture -> Texture or nil
187
+ *
188
+ * Returns the object's texture, or +nil+ if it has none.
189
+ *
190
+ * @return [Texture, nil]
191
+ */
122
192
  static VALUE RenderStates_get_texture(VALUE self) {
123
193
  return Get_RenderStates_Wrapper(self)->rb_texture;
124
194
  }
125
195
 
196
+ /* call-seq:
197
+ * texture=(value) -> Texture or nil
198
+ *
199
+ * Sets the object's texture.
200
+ *
201
+ * @return [Texture, nil] +value+
202
+ */
126
203
  static VALUE RenderStates_set_texture(VALUE self, VALUE rb_texture) {
127
204
  RenderStates* states = Get_RenderStates_Wrapper(self);
128
205
 
@@ -142,10 +219,23 @@ static VALUE RenderStates_set_texture(VALUE self, VALUE rb_texture) {
142
219
  return rb_texture;
143
220
  }
144
221
 
222
+ /* call-seq: shader -> Shader or nil
223
+ *
224
+ * Returns the state's shader, or +nil+ if it has none.
225
+ *
226
+ * @return [Shader, nil]
227
+ */
145
228
  static VALUE RenderStates_get_shader(VALUE self) {
146
229
  return Get_RenderStates_Wrapper(self)->rb_shader;
147
230
  }
148
231
 
232
+ /* call-seq:
233
+ * shader=(value) -> Shader or nil
234
+ *
235
+ * Sets the state's shader.
236
+ *
237
+ * @return [Shader, nil] +value+
238
+ */
149
239
  static VALUE RenderStates_set_shader(VALUE self, VALUE rb_shader) {
150
240
  RenderStates* states = Get_RenderStates_Wrapper(self);
151
241
 
@@ -165,8 +255,32 @@ static VALUE RenderStates_set_shader(VALUE self, VALUE rb_shader) {
165
255
  return rb_shader;
166
256
  }
167
257
 
168
- void Init_RenderState(VALUE rb_module) {
169
- rb_cRenderState = rb_define_class_under(rb_module, "RenderState", rb_cObject);
258
+ /* Document-class: SFML::RenderState
259
+ * The set of render states (transform, blend mode, stencil mode,
260
+ * coordinate type, texture, shader) applied when drawing a Drawable to a
261
+ * render target.
262
+ *
263
+ * @!attribute transform
264
+ * The object's transform matrix.
265
+ * @return [Array] the 3x3 row-major transform matrix
266
+ * @!attribute blend_mode
267
+ * The blend mode applied to the draw.
268
+ * @return [BlendMode]
269
+ * @!attribute stencil_mode
270
+ * The stencil mode applied to the draw.
271
+ * @return [StencilMode]
272
+ * @!attribute coordinate_type
273
+ * The type of texture coordinates used.
274
+ * @return [Symbol] either +:pixels+ or +:normalized+
275
+ * @!attribute texture
276
+ * The object's texture, or +nil+ if it has none.
277
+ * @return [Texture, nil]
278
+ * @!attribute shader
279
+ * The shader applied to the draw, or +nil+ if none.
280
+ * @return [Shader, nil]
281
+ */
282
+ void Init_RenderState(VALUE rb_mSFML) {
283
+ rb_cRenderState = rb_define_class_under(rb_mSFML, "RenderState", rb_cObject);
170
284
 
171
285
  rb_define_singleton_method(rb_cRenderState, "new", RenderStates_new, -1);
172
286