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
data/ext/graphics/shape.c CHANGED
@@ -15,38 +15,37 @@
15
15
  #include "core/macros.h"
16
16
 
17
17
  typedef struct {
18
- sfShape *shape;
18
+ sfShape* shape;
19
19
  VALUE rb_self;
20
20
  VALUE rb_texture;
21
21
  } CustomShape;
22
22
 
23
23
  static VALUE rb_cCustomShape;
24
24
 
25
- static void CustomShape_mark(void *ptr) {
26
- CustomShape *shape = ptr;
25
+ static void CustomShape_mark(void* ptr) {
26
+ CustomShape* shape = ptr;
27
27
 
28
28
  rb_gc_mark(shape->rb_self);
29
29
  rb_gc_mark(shape->rb_texture);
30
30
  }
31
31
 
32
- static void CustomShape_free(void *ptr) {
33
- sfShape_destroy(((CustomShape *) ptr)->shape);
32
+ static void CustomShape_free(void* ptr) {
33
+ sfShape_destroy(((CustomShape*)ptr)->shape);
34
34
  free(ptr);
35
35
  }
36
36
 
37
37
  static const rb_data_type_t CustomShape_data_type = {
38
38
  .wrap_struct_name = "SFML::Shape",
39
39
  .function = {.dmark = CustomShape_mark, .dfree = CustomShape_free, .dsize = NULL},
40
- .flags = RUBY_TYPED_FREE_IMMEDIATELY
41
- };
40
+ .flags = RUBY_TYPED_FREE_IMMEDIATELY};
42
41
 
43
- static CustomShape *Get_CustomShape(VALUE self) {
44
- CustomShape *ptr;
42
+ static CustomShape* Get_CustomShape(VALUE self) {
43
+ CustomShape* ptr;
45
44
  TypedData_Get_Struct(self, CustomShape, &CustomShape_data_type, ptr);
46
45
  return ptr;
47
46
  }
48
47
 
49
- static sfShape *Get_CustomShape_Struct(VALUE self) {
48
+ static sfShape* Get_CustomShape_Struct(VALUE self) {
50
49
  return Get_CustomShape(self)->shape;
51
50
  }
52
51
 
@@ -54,51 +53,61 @@ static sfShape *Get_CustomShape_Struct(VALUE self) {
54
53
  C++ (SFML), so exceptions are contained and reported as a degenerate
55
54
  shape instead of unwinding into foreign frames. */
56
55
  static VALUE CustomShape_get_point_count_body(VALUE v) {
57
- CustomShape *shape = (CustomShape *) v;
56
+ CustomShape* shape = (CustomShape*)v;
58
57
 
59
58
  return rb_funcall(shape->rb_self, rb_intern("point_count"), 0);
60
59
  }
61
60
 
62
- static size_t CustomShape_get_point_count(void *userData) {
63
- CustomShape *shape = userData;
61
+ static size_t CustomShape_get_point_count(void* userData) {
62
+ CustomShape* shape = userData;
64
63
  int state = 0;
65
- VALUE count = rb_protect(CustomShape_get_point_count_body, (VALUE) shape, &state);
64
+ VALUE count = rb_protect(CustomShape_get_point_count_body, (VALUE)shape, &state);
66
65
 
67
66
  if (state) {
68
67
  rb_set_errinfo(Qnil);
69
68
  return 0;
70
69
  }
71
70
 
72
- return (size_t) NUM2SIZET(count);
71
+ return (size_t)NUM2SIZET(count);
73
72
  }
74
73
 
75
74
  typedef struct {
76
- CustomShape *shape;
75
+ CustomShape* shape;
77
76
  size_t index;
78
77
  } PointContext;
79
78
 
80
79
  static VALUE CustomShape_get_point_body(VALUE v) {
81
- PointContext *ctx = (PointContext *) v;
80
+ PointContext* ctx = (PointContext*)v;
82
81
 
83
82
  return rb_funcall(ctx->shape->rb_self, rb_intern("point"), 1, SIZET2NUM(ctx->index));
84
83
  }
85
84
 
86
- static sfVector2f CustomShape_get_point(size_t index, void *userData) {
87
- CustomShape *shape = userData;
85
+ static sfVector2f CustomShape_get_point(size_t index, void* userData) {
86
+ CustomShape* shape = userData;
88
87
  PointContext ctx = {.shape = shape, .index = index};
89
88
  int state = 0;
90
- VALUE point = rb_protect(CustomShape_get_point_body, (VALUE) &ctx, &state);
89
+ VALUE point = rb_protect(CustomShape_get_point_body, (VALUE)&ctx, &state);
91
90
 
92
91
  if (state) {
93
92
  rb_set_errinfo(Qnil);
94
- return (sfVector2f) {0, 0};
93
+ return (sfVector2f){0, 0};
95
94
  }
96
95
 
97
96
  return vec2f_from_rb(point);
98
97
  }
99
98
 
99
+ /* call-seq:
100
+ * Shape.new -> Shape
101
+ *
102
+ * A base class meant to be subclassed: override #point_count and #point(i)
103
+ * in Ruby to define the shape's geometry, then call #update! whenever it
104
+ * changes.
105
+ *
106
+ * @return [Shape]
107
+ * @raise [RuntimeError] if the underlying shape cannot be created
108
+ */
100
109
  static VALUE CustomShape_new(VALUE klass) {
101
- CustomShape *ptr = malloc(sizeof(CustomShape));
110
+ CustomShape* ptr = malloc(sizeof(CustomShape));
102
111
  VALUE self;
103
112
 
104
113
  ptr->rb_self = Qnil;
@@ -116,99 +125,237 @@ static VALUE CustomShape_new(VALUE klass) {
116
125
  return self;
117
126
  }
118
127
 
128
+ /* call-seq: update! -> self
129
+ *
130
+ * Recomputes the shape's geometry by calling back into the subclass's
131
+ * #point_count and #point(i). Call this whenever the shape's points
132
+ * change.
133
+ *
134
+ * @return [self]
135
+ */
119
136
  static VALUE CustomShape_update(VALUE self) {
120
137
  sfShape_update(Get_CustomShape_Struct(self));
121
138
  return self;
122
139
  }
123
140
 
141
+ /* call-seq: position -> Vector2
142
+ *
143
+ * Returns the object's position.
144
+ *
145
+ * @return [Vector2]
146
+ */
124
147
  static VALUE CustomShape_get_position(VALUE self) {
125
148
  return vec2f_to_rb(sfShape_getPosition(Get_CustomShape_Struct(self)));
126
149
  }
127
150
 
151
+ /* call-seq:
152
+ * position=(value) -> Vector2
153
+ *
154
+ * Sets the object's position.
155
+ *
156
+ * @return [Vector2] +value+
157
+ */
128
158
  static VALUE CustomShape_set_position(VALUE self, VALUE rb_position) {
129
159
  sfShape_setPosition(Get_CustomShape_Struct(self), vec2f_from_rb(rb_position));
130
160
  return rb_position;
131
161
  }
132
162
 
163
+ /* call-seq: rotation -> Float
164
+ *
165
+ * Returns the object's rotation, in degrees.
166
+ *
167
+ * @return [Float]
168
+ */
133
169
  static VALUE CustomShape_get_rotation(VALUE self) {
134
170
  return DBL2NUM(sfShape_getRotation(Get_CustomShape_Struct(self)));
135
171
  }
136
172
 
173
+ /* call-seq:
174
+ * rotation=(value) -> Float
175
+ *
176
+ * Sets the object's rotation, in degrees.
177
+ *
178
+ * @return [Float] +value+
179
+ */
137
180
  static VALUE CustomShape_set_rotation(VALUE self, VALUE rb_rotation) {
138
181
  sfShape_setRotation(Get_CustomShape_Struct(self), NUM2DBL(rb_rotation));
139
182
  return rb_rotation;
140
183
  }
141
184
 
185
+ /* call-seq: scale -> Vector2
186
+ *
187
+ * Returns the object's scale factors.
188
+ *
189
+ * @return [Vector2]
190
+ */
142
191
  static VALUE CustomShape_get_scale(VALUE self) {
143
192
  return vec2f_to_rb(sfShape_getScale(Get_CustomShape_Struct(self)));
144
193
  }
145
194
 
195
+ /* call-seq:
196
+ * scale=(value) -> Vector2
197
+ *
198
+ * Sets the object's scale factors.
199
+ *
200
+ * @return [Vector2] +value+
201
+ */
146
202
  static VALUE CustomShape_set_scale(VALUE self, VALUE rb_scale) {
147
203
  sfShape_setScale(Get_CustomShape_Struct(self), vec2f_from_rb(rb_scale));
148
204
  return rb_scale;
149
205
  }
150
206
 
207
+ /* call-seq: origin -> Vector2
208
+ *
209
+ * Returns the object's origin.
210
+ *
211
+ * @return [Vector2]
212
+ */
151
213
  static VALUE CustomShape_get_origin(VALUE self) {
152
214
  return vec2f_to_rb(sfShape_getOrigin(Get_CustomShape_Struct(self)));
153
215
  }
154
216
 
217
+ /* call-seq:
218
+ * origin=(value) -> Vector2
219
+ *
220
+ * Sets the object's origin.
221
+ *
222
+ * @return [Vector2] +value+
223
+ */
155
224
  static VALUE CustomShape_set_origin(VALUE self, VALUE rb_origin) {
156
225
  sfShape_setOrigin(Get_CustomShape_Struct(self), vec2f_from_rb(rb_origin));
157
226
  return rb_origin;
158
227
  }
159
228
 
229
+ /* call-seq: move(offset) -> self
230
+ *
231
+ * Moves the object by +offset+.
232
+ *
233
+ * @return [self]
234
+ */
160
235
  static VALUE CustomShape_move(VALUE self, VALUE rb_offset) {
161
236
  sfShape_move(Get_CustomShape_Struct(self), vec2f_from_rb(rb_offset));
162
237
  return self;
163
238
  }
164
239
 
240
+ /* call-seq: rotate(angle) -> self
241
+ *
242
+ * Rotates the object by +angle+ degrees.
243
+ *
244
+ * @return [self]
245
+ */
165
246
  static VALUE CustomShape_rotate(VALUE self, VALUE rb_angle) {
166
247
  sfShape_rotate(Get_CustomShape_Struct(self), NUM2DBL(rb_angle));
167
248
  return self;
168
249
  }
169
250
 
251
+ /* call-seq:
252
+ * scale!(factors) -> self
253
+ *
254
+ * Scales the object by +factors+ relative to its current scale.
255
+ *
256
+ * @return [self]
257
+ */
170
258
  static VALUE CustomShape_scale(VALUE self, VALUE rb_factors) {
171
259
  sfShape_scale(Get_CustomShape_Struct(self), vec2f_from_rb(rb_factors));
172
260
  return self;
173
261
  }
174
262
 
263
+ /* call-seq: transform -> Array
264
+ *
265
+ * Also available as #matrix.
266
+ *
267
+ * @return [Array] the 3x3 row-major transform matrix
268
+ */
175
269
  static VALUE CustomShape_get_transform(VALUE self) {
176
270
  return Transform_MatrixToArray(sfShape_getTransform(Get_CustomShape_Struct(self)).matrix);
177
271
  }
178
272
 
273
+ /* call-seq: inverse_transform -> Array
274
+ *
275
+ * Returns the 3x3 row-major inverse of the object's transform matrix.
276
+ *
277
+ * @return [Array] the 3x3 row-major inverse transform matrix
278
+ */
179
279
  static VALUE CustomShape_get_inverse_transform(VALUE self) {
180
- return Transform_MatrixToArray(sfShape_getInverseTransform(Get_CustomShape_Struct(self)).matrix);
280
+ return Transform_MatrixToArray(
281
+ sfShape_getInverseTransform(Get_CustomShape_Struct(self)).matrix);
181
282
  }
182
283
 
284
+ /* call-seq: fill_color -> Color
285
+ *
286
+ * Returns the shape's fill color.
287
+ *
288
+ * @return [Color]
289
+ */
183
290
  static VALUE CustomShape_get_fill_color(VALUE self) {
184
291
  return color_to_rb(sfShape_getFillColor(Get_CustomShape_Struct(self)));
185
292
  }
186
293
 
294
+ /* call-seq:
295
+ * fill_color=(value) -> Color
296
+ *
297
+ * Sets the shape's fill color.
298
+ *
299
+ * @return [Color] +value+
300
+ */
187
301
  static VALUE CustomShape_set_fill_color(VALUE self, VALUE rb_color) {
188
302
  sfShape_setFillColor(Get_CustomShape_Struct(self), color_from_rb(rb_color));
189
303
  return rb_color;
190
304
  }
191
305
 
306
+ /* call-seq: outline_color -> Color
307
+ *
308
+ * Returns the shape's outline color.
309
+ *
310
+ * @return [Color]
311
+ */
192
312
  static VALUE CustomShape_get_outline_color(VALUE self) {
193
313
  return color_to_rb(sfShape_getOutlineColor(Get_CustomShape_Struct(self)));
194
314
  }
195
315
 
316
+ /* call-seq:
317
+ * outline_color=(value) -> Color
318
+ *
319
+ * Sets the shape's outline color.
320
+ *
321
+ * @return [Color] +value+
322
+ */
196
323
  static VALUE CustomShape_set_outline_color(VALUE self, VALUE rb_color) {
197
324
  sfShape_setOutlineColor(Get_CustomShape_Struct(self), color_from_rb(rb_color));
198
325
  return rb_color;
199
326
  }
200
327
 
328
+ /* call-seq: outline_thickness -> Float
329
+ *
330
+ * Returns the shape's outline thickness.
331
+ *
332
+ * @return [Float]
333
+ */
201
334
  static VALUE CustomShape_get_outline_thickness(VALUE self) {
202
335
  return DBL2NUM(sfShape_getOutlineThickness(Get_CustomShape_Struct(self)));
203
336
  }
204
337
 
338
+ /* call-seq:
339
+ * outline_thickness=(value) -> Float
340
+ *
341
+ * Sets the shape's outline thickness.
342
+ *
343
+ * @return [Float] +value+
344
+ */
205
345
  static VALUE CustomShape_set_outline_thickness(VALUE self, VALUE rb_thickness) {
206
346
  sfShape_setOutlineThickness(Get_CustomShape_Struct(self), NUM2DBL(rb_thickness));
207
347
  return rb_thickness;
208
348
  }
209
349
 
350
+ /* call-seq:
351
+ * texture=(value) -> Texture or nil
352
+ *
353
+ * Sets the object's texture.
354
+ *
355
+ * @return [Texture, nil] +value+
356
+ */
210
357
  static VALUE CustomShape_set_texture(VALUE self, VALUE rb_texture) {
211
- CustomShape *ptr = Get_CustomShape(self);
358
+ CustomShape* ptr = Get_CustomShape(self);
212
359
 
213
360
  if (NIL_P(rb_texture)) {
214
361
  ptr->rb_texture = Qnil;
@@ -226,31 +373,75 @@ static VALUE CustomShape_set_texture(VALUE self, VALUE rb_texture) {
226
373
  return rb_texture;
227
374
  }
228
375
 
376
+ /* call-seq: texture -> Texture or nil
377
+ *
378
+ * Returns the object's texture, or +nil+ if it has none.
379
+ *
380
+ * @return [Texture, nil]
381
+ */
229
382
  static VALUE CustomShape_get_texture(VALUE self) {
230
383
  return Get_CustomShape(self)->rb_texture;
231
384
  }
232
385
 
386
+ /* call-seq: texture_rect -> Rect
387
+ *
388
+ * Returns the sub-rectangle of the texture displayed on the object.
389
+ *
390
+ * @return [Rect] the sub-rectangle of the texture displayed on the shape
391
+ */
233
392
  static VALUE CustomShape_get_texture_rect(VALUE self) {
234
393
  return int_rect_to_rb(sfShape_getTextureRect(Get_CustomShape_Struct(self)));
235
394
  }
236
395
 
396
+ /* call-seq:
397
+ * texture_rect=(value) -> Rect
398
+ *
399
+ * Sets the sub-rectangle of the texture displayed on the object.
400
+ *
401
+ * @return [Rect] +value+
402
+ */
237
403
  static VALUE CustomShape_set_texture_rect(VALUE self, VALUE rb_rect) {
238
404
  sfShape_setTextureRect(Get_CustomShape_Struct(self), int_rect_from_rb(rb_rect));
239
405
  return rb_rect;
240
406
  }
241
407
 
408
+ /* call-seq: geometric_center -> Vector2
409
+ *
410
+ * Returns the local position of the shape's geometric center.
411
+ *
412
+ * @return [Vector2] the local position of the shape's geometric center
413
+ */
242
414
  static VALUE CustomShape_get_geometric_center(VALUE self) {
243
415
  return vec2f_to_rb(sfShape_getGeometricCenter(Get_CustomShape_Struct(self)));
244
416
  }
245
417
 
418
+ /* call-seq: local_bounds -> Rect
419
+ *
420
+ * Returns the bounding box in local (untransformed) coordinates.
421
+ *
422
+ * @return [Rect] the bounding box in local (untransformed) coordinates
423
+ */
246
424
  static VALUE CustomShape_get_local_bounds(VALUE self) {
247
425
  return rect_to_rb(sfShape_getLocalBounds(Get_CustomShape_Struct(self)));
248
426
  }
249
427
 
428
+ /* call-seq: global_bounds -> Rect
429
+ *
430
+ * Returns the bounding box after the transform is applied.
431
+ *
432
+ * @return [Rect] the bounding box after transform is applied
433
+ */
250
434
  static VALUE CustomShape_get_global_bounds(VALUE self) {
251
435
  return rect_to_rb(sfShape_getGlobalBounds(Get_CustomShape_Struct(self)));
252
436
  }
253
437
 
438
+ /* call-seq:
439
+ * draw(target, state) -> nil
440
+ *
441
+ * Draws the object onto +target+ using the given render +state+.
442
+ *
443
+ * @return [nil]
444
+ */
254
445
  static VALUE CustomShape_draw(VALUE self, VALUE rb_target, VALUE rb_state) {
255
446
  if (!rb_obj_is_kind_of(rb_target, Get_Klass_Target())) {
256
447
  raise_invalid_argument_class(Get_Klass_Target());
@@ -266,8 +457,43 @@ static VALUE CustomShape_draw(VALUE self, VALUE rb_target, VALUE rb_state) {
266
457
  return Qnil;
267
458
  }
268
459
 
269
- void Init_Shape(VALUE rb_module) {
270
- rb_cCustomShape = rb_define_class_under(rb_module, "Shape", rb_cObject);
460
+ /* Document-class: SFML::Shape
461
+ * A base class for user-defined shapes. Subclass it and implement
462
+ * #point_count and #point(index) in Ruby to describe the shape's geometry,
463
+ * then call #update! after construction and whenever the points change.
464
+ * Drawable, transformable and stylable like the other SFML shapes.
465
+ * Includes Drawable.
466
+ *
467
+ * @!attribute position
468
+ * The object's position.
469
+ * @return [Vector2]
470
+ * @!attribute rotation
471
+ * The object's rotation, in degrees.
472
+ * @return [Float]
473
+ * @!attribute scale
474
+ * The object's scale factors.
475
+ * @return [Vector2]
476
+ * @!attribute origin
477
+ * The object's origin.
478
+ * @return [Vector2]
479
+ * @!attribute fill_color
480
+ * The object's fill color.
481
+ * @return [Color]
482
+ * @!attribute outline_color
483
+ * The object's outline color.
484
+ * @return [Color]
485
+ * @!attribute outline_thickness
486
+ * The object's outline thickness.
487
+ * @return [Float]
488
+ * @!attribute texture
489
+ * The object's texture, or +nil+ if it has none.
490
+ * @return [Texture, nil]
491
+ * @!attribute texture_rect
492
+ * The sub-rectangle of the texture displayed on the object.
493
+ * @return [Rect]
494
+ */
495
+ void Init_Shape(VALUE rb_mSFML) {
496
+ rb_cCustomShape = rb_define_class_under(rb_mSFML, "Shape", rb_cObject);
271
497
 
272
498
  rb_include_module(rb_cCustomShape, Get_Module_Drawable());
273
499