sfml3-rb 0.2.2 → 0.3.1

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 (148) hide show
  1. checksums.yaml +4 -4
  2. data/.yardopts +9 -0
  3. data/CHANGELOG.md +67 -16
  4. data/README.md +123 -32
  5. data/TODO.md +18 -11
  6. data/ext/audio/audio_enums.c +58 -20
  7. data/ext/audio/listener.c +89 -6
  8. data/ext/audio/music.c +212 -5
  9. data/ext/audio/sound.c +218 -9
  10. data/ext/audio/sound_buffer.c +197 -47
  11. data/ext/audio/sound_buffer_recorder.c +90 -18
  12. data/ext/audio/sound_recorder.c +188 -58
  13. data/ext/audio/sound_source_cone.c +127 -33
  14. data/ext/audio/sound_stream.c +204 -21
  15. data/ext/core/exceptions.c +10 -8
  16. data/ext/core/unicode.c +12 -2
  17. data/ext/ext.c +8 -0
  18. data/ext/graphics/blend_mode.c +218 -60
  19. data/ext/graphics/circle.c +300 -16
  20. data/ext/graphics/color.c +253 -94
  21. data/ext/graphics/drawable.c +16 -4
  22. data/ext/graphics/font.c +144 -25
  23. data/ext/graphics/glyph.c +38 -8
  24. data/ext/graphics/image.c +205 -41
  25. data/ext/graphics/polygon.c +317 -30
  26. data/ext/graphics/rect.c +225 -60
  27. data/ext/graphics/rectangle.c +307 -35
  28. data/ext/graphics/render_state.c +124 -12
  29. data/ext/graphics/render_texture.c +191 -14
  30. data/ext/graphics/render_window.c +55 -0
  31. data/ext/graphics/render_window.h +10 -0
  32. data/ext/graphics/shader.c +289 -17
  33. data/ext/graphics/shape.c +265 -32
  34. data/ext/graphics/sprite.c +245 -30
  35. data/ext/graphics/stencil_mode.c +163 -46
  36. data/ext/graphics/target.c +121 -43
  37. data/ext/graphics/target.h +31 -17
  38. data/ext/graphics/text.c +339 -19
  39. data/ext/graphics/texture.c +291 -6
  40. data/ext/graphics/transform.c +178 -5
  41. data/ext/graphics/transformable.c +127 -12
  42. data/ext/graphics/vertex.c +98 -6
  43. data/ext/graphics/vertex_array.c +142 -21
  44. data/ext/graphics/vertex_buffer.c +154 -12
  45. data/ext/graphics/view.c +140 -6
  46. data/ext/network/ftp.c +278 -12
  47. data/ext/network/http.c +179 -44
  48. data/ext/network/ip_address.c +127 -35
  49. data/ext/network/network_enums.c +248 -141
  50. data/ext/network/packet.c +280 -41
  51. data/ext/network/socket_selector.c +98 -21
  52. data/ext/network/tcp_listener.c +82 -18
  53. data/ext/network/tcp_socket.c +135 -27
  54. data/ext/network/udp_socket.c +129 -28
  55. data/ext/ports.rb +7 -0
  56. data/ext/system/buffer.c +47 -16
  57. data/ext/system/clock.c +77 -12
  58. data/ext/system/input_stream.c +113 -51
  59. data/ext/system/sleep.c +10 -2
  60. data/ext/system/time.c +182 -40
  61. data/ext/system/vec2.c +166 -39
  62. data/ext/system/vec3.c +177 -39
  63. data/ext/window/clipboard.c +47 -17
  64. data/ext/window/context.c +66 -13
  65. data/ext/window/context_settings.c +132 -42
  66. data/ext/window/cursor.c +45 -9
  67. data/ext/window/event.c +164 -53
  68. data/ext/window/joystick.c +69 -3
  69. data/ext/window/keyboard.c +168 -116
  70. data/ext/window/mouse.c +64 -13
  71. data/ext/window/sensor.c +28 -2
  72. data/ext/window/touch.c +32 -12
  73. data/ext/window/video_mode.c +93 -31
  74. data/ext/window/vulkan.c +34 -6
  75. data/ext/window/window.c +228 -229
  76. data/ext/window/window.h +4 -4
  77. data/ext/window/window_base.c +251 -0
  78. data/ext/window/window_base.h +43 -0
  79. data/ext/window/window_base.inc +236 -0
  80. data/lib/sfml/version.rb +1 -1
  81. data/sig/audio/audio_enums.rbs +30 -0
  82. data/sig/audio/listener.rbs +16 -0
  83. data/sig/audio/music.rbs +56 -0
  84. data/sig/audio/sound.rbs +51 -0
  85. data/sig/audio/sound_buffer.rbs +17 -0
  86. data/sig/audio/sound_buffer_recorder.rbs +14 -0
  87. data/sig/audio/sound_recorder.rbs +17 -0
  88. data/sig/audio/sound_source_cone.rbs +14 -0
  89. data/sig/audio/sound_stream.rbs +51 -0
  90. data/sig/graphics/blend_mode.rbs +29 -0
  91. data/sig/graphics/circle.rbs +44 -0
  92. data/sig/graphics/color.rbs +39 -0
  93. data/sig/graphics/drawable.rbs +5 -0
  94. data/sig/graphics/font.rbs +20 -0
  95. data/sig/graphics/glyph.rbs +7 -0
  96. data/sig/graphics/image.rbs +22 -0
  97. data/sig/graphics/polygon.rbs +42 -0
  98. data/sig/graphics/rect.rbs +33 -0
  99. data/sig/graphics/rectangle.rbs +42 -0
  100. data/sig/graphics/render_state.rbs +21 -0
  101. data/sig/graphics/render_target.rbs +18 -0
  102. data/sig/graphics/render_texture.rbs +39 -0
  103. data/sig/graphics/render_window.rbs +7 -0
  104. data/sig/graphics/shader.rbs +39 -0
  105. data/sig/graphics/shape.rbs +38 -0
  106. data/sig/graphics/sprite.rbs +34 -0
  107. data/sig/graphics/stencil_mode.rbs +18 -0
  108. data/sig/graphics/target.rbs +8 -0
  109. data/sig/graphics/text.rbs +48 -0
  110. data/sig/graphics/texture.rbs +34 -0
  111. data/sig/graphics/transform.rbs +37 -0
  112. data/sig/graphics/transformable.rbs +25 -0
  113. data/sig/graphics/vertex.rbs +17 -0
  114. data/sig/graphics/vertex_array.rbs +17 -0
  115. data/sig/graphics/vertex_buffer.rbs +22 -0
  116. data/sig/graphics/view.rbs +23 -0
  117. data/sig/network/ftp.rbs +46 -0
  118. data/sig/network/http.rbs +27 -0
  119. data/sig/network/ip_address.rbs +22 -0
  120. data/sig/network/network_enums.rbs +95 -0
  121. data/sig/network/packet.rbs +40 -0
  122. data/sig/network/socket_selector.rbs +14 -0
  123. data/sig/network/tcp_listener.rbs +13 -0
  124. data/sig/network/tcp_socket.rbs +18 -0
  125. data/sig/network/udp_socket.rbs +17 -0
  126. data/sig/sfml/version.rbs +3 -0
  127. data/sig/system/buffer.rbs +11 -0
  128. data/sig/system/clock.rbs +13 -0
  129. data/sig/system/input_stream.rbs +7 -0
  130. data/sig/system/sleep.rbs +3 -0
  131. data/sig/system/time.rbs +28 -0
  132. data/sig/system/vec2.rbs +26 -0
  133. data/sig/system/vec3.rbs +27 -0
  134. data/sig/window/clipboard.rbs +8 -0
  135. data/sig/window/context.rbs +11 -0
  136. data/sig/window/context_settings.rbs +20 -0
  137. data/sig/window/cursor.rbs +6 -0
  138. data/sig/window/event.rbs +20 -0
  139. data/sig/window/joystick.rbs +15 -0
  140. data/sig/window/keyboard.rbs +10 -0
  141. data/sig/window/mouse.rbs +9 -0
  142. data/sig/window/sensor.rbs +8 -0
  143. data/sig/window/touch.rbs +6 -0
  144. data/sig/window/video_mode.rbs +16 -0
  145. data/sig/window/vulkan.rbs +7 -0
  146. data/sig/window/window.rbs +34 -0
  147. data/sig/window/window_base.rbs +33 -0
  148. metadata +76 -3
@@ -15,39 +15,38 @@
15
15
  #include "core/macros.h"
16
16
 
17
17
  typedef struct {
18
- sfConvexShape *shape;
18
+ sfConvexShape* shape;
19
19
  VALUE rb_texture;
20
20
  } ConvexShape;
21
21
 
22
22
  static VALUE rb_cConvexShape;
23
23
 
24
- static void ConvexShape_mark(void *ptr) {
25
- rb_gc_mark(((ConvexShape *) ptr)->rb_texture);
24
+ static void ConvexShape_mark(void* ptr) {
25
+ rb_gc_mark(((ConvexShape*)ptr)->rb_texture);
26
26
  }
27
27
 
28
- static void ConvexShape_free(void *ptr) {
29
- sfConvexShape_destroy(((ConvexShape *) ptr)->shape);
28
+ static void ConvexShape_free(void* ptr) {
29
+ sfConvexShape_destroy(((ConvexShape*)ptr)->shape);
30
30
  free(ptr);
31
31
  }
32
32
 
33
33
  static const rb_data_type_t ConvexShape_data_type = {
34
34
  .wrap_struct_name = "SFML::ConvexShape",
35
35
  .function = {.dmark = ConvexShape_mark, .dfree = ConvexShape_free, .dsize = NULL},
36
- .flags = RUBY_TYPED_FREE_IMMEDIATELY
37
- };
36
+ .flags = RUBY_TYPED_FREE_IMMEDIATELY};
38
37
 
39
- static ConvexShape *Get_ConvexShape(VALUE self) {
40
- ConvexShape *ptr;
38
+ static ConvexShape* Get_ConvexShape(VALUE self) {
39
+ ConvexShape* ptr;
41
40
  TypedData_Get_Struct(self, ConvexShape, &ConvexShape_data_type, ptr);
42
41
  return ptr;
43
42
  }
44
43
 
45
- static sfConvexShape *Get_ConvexShape_Struct(VALUE self) {
44
+ static sfConvexShape* Get_ConvexShape_Struct(VALUE self) {
46
45
  return Get_ConvexShape(self)->shape;
47
46
  }
48
47
 
49
- static VALUE ConvexShape_wrap(VALUE klass, sfConvexShape *shape) {
50
- ConvexShape *ptr;
48
+ static VALUE ConvexShape_wrap(VALUE klass, sfConvexShape* shape) {
49
+ ConvexShape* ptr;
51
50
 
52
51
  if (shape == NULL) {
53
52
  rb_raise(rb_eRuntimeError, "failed to create convex shape");
@@ -60,25 +59,59 @@ static VALUE ConvexShape_wrap(VALUE klass, sfConvexShape *shape) {
60
59
  return TypedData_Wrap_Struct(klass, &ConvexShape_data_type, ptr);
61
60
  }
62
61
 
63
- static VALUE ConvexShape_new(int argc, VALUE *argv, VALUE klass) {
64
- sfConvexShape *shape = sfConvexShape_create();
62
+ static VALUE ConvexShape_alloc(VALUE klass) {
63
+ ConvexShape* ptr = malloc(sizeof(ConvexShape));
64
+ sfConvexShape* shape;
65
+
66
+ if (ptr == NULL) {
67
+ rb_raise(rb_eNoMemError, "failed to allocate convex shape");
68
+ }
69
+
70
+ shape = sfConvexShape_create();
71
+
72
+ if (shape == NULL) {
73
+ free(ptr);
74
+ rb_raise(rb_eRuntimeError, "failed to create convex shape");
75
+ }
76
+
77
+ ptr->shape = shape;
78
+ ptr->rb_texture = Qnil;
79
+
80
+ return TypedData_Wrap_Struct(klass, &ConvexShape_data_type, ptr);
81
+ }
82
+
83
+ /* call-seq:
84
+ * ConvexShape.new(point_count = 0) -> ConvexShape
85
+ *
86
+ * Creates a convex shape with room for at least +point_count+ points.
87
+ *
88
+ * @return [ConvexShape]
89
+ */
90
+ static VALUE ConvexShape_initialize(int argc, VALUE* argv, VALUE self) {
65
91
  VALUE rb_point_count;
66
92
 
67
93
  rb_scan_args(argc, argv, "01", &rb_point_count);
68
94
 
69
95
  if (!NIL_P(rb_point_count)) {
70
- sfConvexShape_setPointCount(shape, (size_t) NUM2SIZET(rb_point_count));
96
+ sfConvexShape_setPointCount(Get_ConvexShape_Struct(self),
97
+ (size_t)NUM2SIZET(rb_point_count));
71
98
  }
72
99
 
73
- return ConvexShape_wrap(klass, shape);
100
+ return self;
74
101
  }
75
102
 
103
+ /* call-seq: copy -> ConvexShape
104
+ *
105
+ * Returns a deep copy of the object.
106
+ *
107
+ * @return [ConvexShape] an independent copy, including its texture reference
108
+ */
76
109
  static VALUE ConvexShape_copy(VALUE self) {
77
- ConvexShape *ptr = Get_ConvexShape(self);
110
+ ConvexShape* ptr = Get_ConvexShape(self);
78
111
  VALUE copy = ConvexShape_wrap(Get_Klass_ConvexShape(), sfConvexShape_copy(ptr->shape));
79
112
 
80
113
  if (!NIL_P(ptr->rb_texture)) {
81
- ConvexShape *copy_ptr = Get_ConvexShape(copy);
114
+ ConvexShape* copy_ptr = Get_ConvexShape(copy);
82
115
 
83
116
  copy_ptr->rb_texture = ptr->rb_texture;
84
117
  sfConvexShape_setTexture(copy_ptr->shape, Get_Texture_Struct(ptr->rb_texture), false);
@@ -87,112 +120,283 @@ static VALUE ConvexShape_copy(VALUE self) {
87
120
  return copy;
88
121
  }
89
122
 
123
+ /* call-seq: point_count -> Integer
124
+ *
125
+ * Returns the number of points composing the shape.
126
+ *
127
+ * @return [Integer]
128
+ */
90
129
  static VALUE ConvexShape_get_point_count(VALUE self) {
91
130
  return SIZET2NUM(sfConvexShape_getPointCount(Get_ConvexShape_Struct(self)));
92
131
  }
93
132
 
133
+ /* call-seq:
134
+ * point_count=(value) -> Integer
135
+ *
136
+ * Sets the number of points composing the shape.
137
+ *
138
+ * @return [Integer] +value+
139
+ */
94
140
  static VALUE ConvexShape_set_point_count(VALUE self, VALUE rb_count) {
95
- sfConvexShape_setPointCount(Get_ConvexShape_Struct(self), (size_t) NUM2SIZET(rb_count));
141
+ sfConvexShape_setPointCount(Get_ConvexShape_Struct(self), (size_t)NUM2SIZET(rb_count));
96
142
  return rb_count;
97
143
  }
98
144
 
145
+ static size_t ConvexShape_check_index(VALUE self, VALUE rb_index) {
146
+ void* shape = Get_ConvexShape_Struct(self);
147
+ size_t index = (size_t)NUM2SIZET(rb_index);
148
+ size_t count = sfConvexShape_getPointCount(shape);
149
+
150
+ if (index >= count) {
151
+ rb_raise(rb_eIndexError, "index %zu outside of point count %zu", index, count);
152
+ }
153
+
154
+ return index;
155
+ }
156
+
157
+ /* call-seq: point(index) -> Vector2
158
+ *
159
+ * Returns the local position of the point at +index+.
160
+ *
161
+ * @return [Vector2] the local position of the point at +index+
162
+ * @raise [IndexError] if +index+ is out of range
163
+ */
99
164
  static VALUE ConvexShape_get_point(VALUE self, VALUE rb_index) {
100
- return vec2f_to_rb(sfConvexShape_getPoint(Get_ConvexShape_Struct(self), (size_t) NUM2SIZET(rb_index)));
165
+ return vec2f_to_rb(sfConvexShape_getPoint(Get_ConvexShape_Struct(self),
166
+ ConvexShape_check_index(self, rb_index)));
101
167
  }
102
168
 
169
+ /* call-seq: set_point(index, point) -> Vector2
170
+ *
171
+ * Sets the position of the point at +index+.
172
+ *
173
+ * @return [Vector2] +point+
174
+ * @raise [IndexError] if +index+ is out of range
175
+ */
103
176
  static VALUE ConvexShape_set_point(VALUE self, VALUE rb_index, VALUE rb_point) {
104
- sfConvexShape_setPoint(Get_ConvexShape_Struct(self), (size_t) NUM2SIZET(rb_index), vec2f_from_rb(rb_point));
177
+ sfConvexShape_setPoint(Get_ConvexShape_Struct(self), ConvexShape_check_index(self, rb_index),
178
+ vec2f_from_rb(rb_point));
105
179
  return rb_point;
106
180
  }
107
181
 
182
+ /* call-seq: position -> Vector2
183
+ *
184
+ * Returns the object's position.
185
+ *
186
+ * @return [Vector2]
187
+ */
108
188
  static VALUE ConvexShape_get_position(VALUE self) {
109
189
  return vec2f_to_rb(sfConvexShape_getPosition(Get_ConvexShape_Struct(self)));
110
190
  }
111
191
 
192
+ /* call-seq:
193
+ * position=(value) -> Vector2
194
+ *
195
+ * Sets the object's position.
196
+ *
197
+ * @return [Vector2] +value+
198
+ */
112
199
  static VALUE ConvexShape_set_position(VALUE self, VALUE rb_position) {
113
200
  sfConvexShape_setPosition(Get_ConvexShape_Struct(self), vec2f_from_rb(rb_position));
114
201
  return rb_position;
115
202
  }
116
203
 
204
+ /* call-seq: rotation -> Float
205
+ *
206
+ * Returns the object's rotation, in degrees.
207
+ *
208
+ * @return [Float]
209
+ */
117
210
  static VALUE ConvexShape_get_rotation(VALUE self) {
118
211
  return DBL2NUM(sfConvexShape_getRotation(Get_ConvexShape_Struct(self)));
119
212
  }
120
213
 
214
+ /* call-seq:
215
+ * rotation=(value) -> Float
216
+ *
217
+ * Sets the object's rotation, in degrees.
218
+ *
219
+ * @return [Float] +value+
220
+ */
121
221
  static VALUE ConvexShape_set_rotation(VALUE self, VALUE rb_rotation) {
122
222
  sfConvexShape_setRotation(Get_ConvexShape_Struct(self), NUM2DBL(rb_rotation));
123
223
  return rb_rotation;
124
224
  }
125
225
 
226
+ /* call-seq: scale -> Vector2
227
+ *
228
+ * Returns the object's scale factors.
229
+ *
230
+ * @return [Vector2]
231
+ */
126
232
  static VALUE ConvexShape_get_scale(VALUE self) {
127
233
  return vec2f_to_rb(sfConvexShape_getScale(Get_ConvexShape_Struct(self)));
128
234
  }
129
235
 
236
+ /* call-seq:
237
+ * scale=(value) -> Vector2
238
+ *
239
+ * Sets the object's scale factors.
240
+ *
241
+ * @return [Vector2] +value+
242
+ */
130
243
  static VALUE ConvexShape_set_scale(VALUE self, VALUE rb_scale) {
131
244
  sfConvexShape_setScale(Get_ConvexShape_Struct(self), vec2f_from_rb(rb_scale));
132
245
  return rb_scale;
133
246
  }
134
247
 
248
+ /* call-seq: origin -> Vector2
249
+ *
250
+ * Returns the object's origin.
251
+ *
252
+ * @return [Vector2]
253
+ */
135
254
  static VALUE ConvexShape_get_origin(VALUE self) {
136
255
  return vec2f_to_rb(sfConvexShape_getOrigin(Get_ConvexShape_Struct(self)));
137
256
  }
138
257
 
258
+ /* call-seq:
259
+ * origin=(value) -> Vector2
260
+ *
261
+ * Sets the object's origin.
262
+ *
263
+ * @return [Vector2] +value+
264
+ */
139
265
  static VALUE ConvexShape_set_origin(VALUE self, VALUE rb_origin) {
140
266
  sfConvexShape_setOrigin(Get_ConvexShape_Struct(self), vec2f_from_rb(rb_origin));
141
267
  return rb_origin;
142
268
  }
143
269
 
270
+ /* call-seq: move(offset) -> self
271
+ *
272
+ * Moves the object by +offset+.
273
+ *
274
+ * @return [self]
275
+ */
144
276
  static VALUE ConvexShape_move(VALUE self, VALUE rb_offset) {
145
277
  sfConvexShape_move(Get_ConvexShape_Struct(self), vec2f_from_rb(rb_offset));
146
278
  return self;
147
279
  }
148
280
 
281
+ /* call-seq: rotate(angle) -> self
282
+ *
283
+ * Rotates the object by +angle+ degrees.
284
+ *
285
+ * @return [self]
286
+ */
149
287
  static VALUE ConvexShape_rotate(VALUE self, VALUE rb_angle) {
150
288
  sfConvexShape_rotate(Get_ConvexShape_Struct(self), NUM2DBL(rb_angle));
151
289
  return self;
152
290
  }
153
291
 
292
+ /* call-seq:
293
+ * scale!(factors) -> self
294
+ *
295
+ * Scales the object by +factors+ relative to its current scale.
296
+ *
297
+ * @return [self]
298
+ */
154
299
  static VALUE ConvexShape_scale(VALUE self, VALUE rb_factors) {
155
300
  sfConvexShape_scale(Get_ConvexShape_Struct(self), vec2f_from_rb(rb_factors));
156
301
  return self;
157
302
  }
158
303
 
304
+ /* call-seq: transform -> Array
305
+ *
306
+ * Also available as #matrix.
307
+ *
308
+ * @return [Array] the 3x3 row-major transform matrix
309
+ */
159
310
  static VALUE ConvexShape_get_transform(VALUE self) {
160
311
  return Transform_MatrixToArray(sfConvexShape_getTransform(Get_ConvexShape_Struct(self)).matrix);
161
312
  }
162
313
 
314
+ /* call-seq: inverse_transform -> Array
315
+ *
316
+ * Returns the 3x3 row-major inverse of the object's transform matrix.
317
+ *
318
+ * @return [Array] the 3x3 row-major inverse transform matrix
319
+ */
163
320
  static VALUE ConvexShape_get_inverse_transform(VALUE self) {
164
- return Transform_MatrixToArray(sfConvexShape_getInverseTransform(Get_ConvexShape_Struct(self)).matrix);
321
+ return Transform_MatrixToArray(
322
+ sfConvexShape_getInverseTransform(Get_ConvexShape_Struct(self)).matrix);
165
323
  }
166
324
 
325
+ /* call-seq: fill_color -> Color
326
+ *
327
+ * Returns the shape's fill color.
328
+ *
329
+ * @return [Color]
330
+ */
167
331
  static VALUE ConvexShape_get_fill_color(VALUE self) {
168
332
  return color_to_rb(sfConvexShape_getFillColor(Get_ConvexShape_Struct(self)));
169
333
  }
170
334
 
335
+ /* call-seq:
336
+ * fill_color=(value) -> Color
337
+ *
338
+ * Sets the shape's fill color.
339
+ *
340
+ * @return [Color] +value+
341
+ */
171
342
  static VALUE ConvexShape_set_fill_color(VALUE self, VALUE rb_color) {
172
343
  sfConvexShape_setFillColor(Get_ConvexShape_Struct(self), color_from_rb(rb_color));
173
344
  return rb_color;
174
345
  }
175
346
 
347
+ /* call-seq: outline_color -> Color
348
+ *
349
+ * Returns the shape's outline color.
350
+ *
351
+ * @return [Color]
352
+ */
176
353
  static VALUE ConvexShape_get_outline_color(VALUE self) {
177
354
  return color_to_rb(sfConvexShape_getOutlineColor(Get_ConvexShape_Struct(self)));
178
355
  }
179
356
 
357
+ /* call-seq:
358
+ * outline_color=(value) -> Color
359
+ *
360
+ * Sets the shape's outline color.
361
+ *
362
+ * @return [Color] +value+
363
+ */
180
364
  static VALUE ConvexShape_set_outline_color(VALUE self, VALUE rb_color) {
181
365
  sfConvexShape_setOutlineColor(Get_ConvexShape_Struct(self), color_from_rb(rb_color));
182
366
  return rb_color;
183
367
  }
184
368
 
369
+ /* call-seq: outline_thickness -> Float
370
+ *
371
+ * Returns the shape's outline thickness.
372
+ *
373
+ * @return [Float]
374
+ */
185
375
  static VALUE ConvexShape_get_outline_thickness(VALUE self) {
186
376
  return DBL2NUM(sfConvexShape_getOutlineThickness(Get_ConvexShape_Struct(self)));
187
377
  }
188
378
 
379
+ /* call-seq:
380
+ * outline_thickness=(value) -> Float
381
+ *
382
+ * Sets the shape's outline thickness.
383
+ *
384
+ * @return [Float] +value+
385
+ */
189
386
  static VALUE ConvexShape_set_outline_thickness(VALUE self, VALUE rb_thickness) {
190
387
  sfConvexShape_setOutlineThickness(Get_ConvexShape_Struct(self), NUM2DBL(rb_thickness));
191
388
  return rb_thickness;
192
389
  }
193
390
 
391
+ /* call-seq:
392
+ * texture=(value) -> Texture or nil
393
+ *
394
+ * Sets the object's texture.
395
+ *
396
+ * @return [Texture, nil] +value+
397
+ */
194
398
  static VALUE ConvexShape_set_texture(VALUE self, VALUE rb_texture) {
195
- ConvexShape *ptr = Get_ConvexShape(self);
399
+ ConvexShape* ptr = Get_ConvexShape(self);
196
400
 
197
401
  if (NIL_P(rb_texture)) {
198
402
  ptr->rb_texture = Qnil;
@@ -210,52 +414,135 @@ static VALUE ConvexShape_set_texture(VALUE self, VALUE rb_texture) {
210
414
  return rb_texture;
211
415
  }
212
416
 
417
+ /* call-seq: texture -> Texture or nil
418
+ *
419
+ * Returns the object's texture, or +nil+ if it has none.
420
+ *
421
+ * @return [Texture, nil]
422
+ */
213
423
  static VALUE ConvexShape_get_texture(VALUE self) {
214
424
  return Get_ConvexShape(self)->rb_texture;
215
425
  }
216
426
 
427
+ /* call-seq: texture_rect -> Rect
428
+ *
429
+ * Returns the sub-rectangle of the texture displayed on the object.
430
+ *
431
+ * @return [Rect] the sub-rectangle of the texture displayed on the shape
432
+ */
217
433
  static VALUE ConvexShape_get_texture_rect(VALUE self) {
218
434
  return int_rect_to_rb(sfConvexShape_getTextureRect(Get_ConvexShape_Struct(self)));
219
435
  }
220
436
 
437
+ /* call-seq:
438
+ * texture_rect=(value) -> Rect
439
+ *
440
+ * Sets the sub-rectangle of the texture displayed on the object.
441
+ *
442
+ * @return [Rect] +value+
443
+ */
221
444
  static VALUE ConvexShape_set_texture_rect(VALUE self, VALUE rb_rect) {
222
445
  sfConvexShape_setTextureRect(Get_ConvexShape_Struct(self), int_rect_from_rb(rb_rect));
223
446
  return rb_rect;
224
447
  }
225
448
 
449
+ /* call-seq: geometric_center -> Vector2
450
+ *
451
+ * Returns the local position of the shape's geometric center.
452
+ *
453
+ * @return [Vector2] the local position of the shape's geometric center
454
+ */
226
455
  static VALUE ConvexShape_get_geometric_center(VALUE self) {
227
456
  return vec2f_to_rb(sfConvexShape_getGeometricCenter(Get_ConvexShape_Struct(self)));
228
457
  }
229
458
 
459
+ /* call-seq: local_bounds -> Rect
460
+ *
461
+ * Returns the bounding box in local (untransformed) coordinates.
462
+ *
463
+ * @return [Rect] the bounding box in local (untransformed) coordinates
464
+ */
230
465
  static VALUE ConvexShape_get_local_bounds(VALUE self) {
231
466
  return rect_to_rb(sfConvexShape_getLocalBounds(Get_ConvexShape_Struct(self)));
232
467
  }
233
468
 
469
+ /* call-seq: global_bounds -> Rect
470
+ *
471
+ * Returns the bounding box after the transform is applied.
472
+ *
473
+ * @return [Rect] the bounding box after transform is applied
474
+ */
234
475
  static VALUE ConvexShape_get_global_bounds(VALUE self) {
235
476
  return rect_to_rb(sfConvexShape_getGlobalBounds(Get_ConvexShape_Struct(self)));
236
477
  }
237
478
 
479
+ /* call-seq:
480
+ * draw(target, state) -> nil
481
+ *
482
+ * Draws the object onto +target+ using the given render +state+.
483
+ *
484
+ * @return [nil]
485
+ */
238
486
  static VALUE ConvexShape_draw(VALUE self, VALUE rb_target, VALUE rb_state) {
239
- if (!rb_obj_is_kind_of(rb_target, Get_Klass_Target())) {
240
- raise_invalid_argument_class(Get_Klass_Target());
241
- }
487
+ TargetView view = Get_RenderTarget_View(rb_target);
242
488
 
243
489
  if (!rb_obj_is_kind_of(rb_state, Get_Klass_RenderState())) {
244
490
  raise_invalid_argument_class(Get_Klass_RenderState());
245
491
  }
246
492
 
247
- TARGET_DRAW(Get_Target_Struct(rb_target), sfRenderWindow_drawConvexShape, sfRenderTexture_drawConvexShape,
493
+ TARGET_DRAW(view, sfRenderWindow_drawConvexShape, sfRenderTexture_drawConvexShape,
248
494
  Get_ConvexShape_Struct(self), Get_RenderState_Struct(rb_state));
249
495
 
250
496
  return Qnil;
251
497
  }
252
498
 
253
- void Init_ConvexShape(VALUE rb_module) {
254
- rb_cConvexShape = rb_define_class_under(rb_module, "ConvexShape", rb_cObject);
499
+ /* Document-class: SFML::ConvexShape
500
+ * A convex polygon shape defined by an arbitrary set of points, drawable,
501
+ * transformable and stylable like the other SFML shapes. Includes
502
+ * Drawable.
503
+ *
504
+ * The polygon must remain convex; passing points that describe a concave
505
+ * shape produces undefined rendering.
506
+ *
507
+ * @!attribute point_count
508
+ * The number of points composing the shape.
509
+ * @return [Integer]
510
+ * @!attribute position
511
+ * The object's position.
512
+ * @return [Vector2]
513
+ * @!attribute rotation
514
+ * The object's rotation, in degrees.
515
+ * @return [Float]
516
+ * @!attribute scale
517
+ * The object's scale factors.
518
+ * @return [Vector2]
519
+ * @!attribute origin
520
+ * The object's origin.
521
+ * @return [Vector2]
522
+ * @!attribute fill_color
523
+ * The object's fill color.
524
+ * @return [Color]
525
+ * @!attribute outline_color
526
+ * The object's outline color.
527
+ * @return [Color]
528
+ * @!attribute outline_thickness
529
+ * The object's outline thickness.
530
+ * @return [Float]
531
+ * @!attribute texture
532
+ * The object's texture, or +nil+ if it has none.
533
+ * @return [Texture, nil]
534
+ * @!attribute texture_rect
535
+ * The sub-rectangle of the texture displayed on the object.
536
+ * @return [Rect]
537
+ */
538
+ void Init_ConvexShape(VALUE rb_mSFML) {
539
+ rb_cConvexShape = rb_define_class_under(rb_mSFML, "ConvexShape", rb_cObject);
540
+
541
+ rb_define_alloc_func(rb_cConvexShape, ConvexShape_alloc);
255
542
 
256
543
  rb_include_module(rb_cConvexShape, Get_Module_Drawable());
257
544
 
258
- rb_define_singleton_method(rb_cConvexShape, "new", ConvexShape_new, -1);
545
+ rb_define_method(rb_cConvexShape, "initialize", ConvexShape_initialize, -1);
259
546
 
260
547
  rb_define_method(rb_cConvexShape, "copy", ConvexShape_copy, 0);
261
548