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/rect.c CHANGED
@@ -13,43 +13,51 @@ typedef struct {
13
13
 
14
14
  static VALUE rb_cRect;
15
15
 
16
- static void Rect_free(void *ptr) {
16
+ static void Rect_free(void* ptr) {
17
17
  free(ptr);
18
18
  }
19
19
 
20
20
  static const rb_data_type_t Rect_data_type = {
21
21
  .wrap_struct_name = "SFML::Rect",
22
22
  .function = {.dmark = NULL, .dfree = Rect_free, .dsize = NULL},
23
- .flags = RUBY_TYPED_FREE_IMMEDIATELY
24
- };
23
+ .flags = RUBY_TYPED_FREE_IMMEDIATELY};
25
24
 
26
25
  static VALUE Rect_wrap(sfFloatRect rect) {
27
- Rect *ptr = malloc(sizeof(Rect));
26
+ Rect* ptr = malloc(sizeof(Rect));
28
27
 
29
28
  ptr->rect = rect;
30
29
 
31
30
  return TypedData_Wrap_Struct(rb_cRect, &Rect_data_type, ptr);
32
31
  }
33
32
 
34
- static VALUE Rect_new(int argc, VALUE *argv, VALUE klass) {
33
+ /* call-seq:
34
+ * Rect.new -> Rect(0, 0, 0, 0)
35
+ * Rect.new(left, top) -> Rect(left, top, 0, 0)
36
+ * Rect.new(left, top, width, height) -> Rect(left, top, width, height)
37
+ * Rect.new([left, top, width, height]) -> Rect(left, top, width, height)
38
+ * Rect.new(other_rect) -> copy of +other_rect+
39
+ *
40
+ * Used for both float rects (positions/sizes) and int rects (pixel
41
+ * sub-regions of a texture); the underlying storage is always Float.
42
+ *
43
+ * @return [Rect]
44
+ * @raise [ArgumentError] if given an Array shorter than 4 elements, or an
45
+ * argument count other than 0, 1, 2 or 4
46
+ */
47
+ static VALUE Rect_new(int argc, VALUE* argv, VALUE klass) {
35
48
  VALUE self;
36
- Rect *ptr;
49
+ Rect* ptr;
37
50
  sfFloatRect rect = {{0, 0}, {0, 0}};
38
51
 
39
52
  if (argc == 1 && rb_obj_is_kind_of(argv[0], rb_cRect)) {
40
- rect = ((Rect *) Get_Rect_Struct(argv[0]))->rect;
53
+ rect = ((Rect*)Get_Rect_Struct(argv[0]))->rect;
41
54
  } else if (argc == 1 && RB_TYPE_P(argv[0], T_ARRAY)) {
42
55
  rect = rect_from_rb(argv[0]);
43
56
  } else if (argc == 2) {
44
- rect = (sfFloatRect) {
45
- {(float) NUM2DBL(argv[0]), (float) NUM2DBL(argv[1])},
46
- {0, 0}
47
- };
57
+ rect = (sfFloatRect){{(float)NUM2DBL(argv[0]), (float)NUM2DBL(argv[1])}, {0, 0}};
48
58
  } else if (argc == 4) {
49
- rect = (sfFloatRect) {
50
- {(float) NUM2DBL(argv[0]), (float) NUM2DBL(argv[1])},
51
- {(float) NUM2DBL(argv[2]), (float) NUM2DBL(argv[3])}
52
- };
59
+ rect = (sfFloatRect){{(float)NUM2DBL(argv[0]), (float)NUM2DBL(argv[1])},
60
+ {(float)NUM2DBL(argv[2]), (float)NUM2DBL(argv[3])}};
53
61
  } else if (argc != 0) {
54
62
  raise_invalid_arguments_excepted(4, argc);
55
63
  }
@@ -62,72 +70,159 @@ static VALUE Rect_new(int argc, VALUE *argv, VALUE klass) {
62
70
  return self;
63
71
  }
64
72
 
73
+ /* call-seq: left -> Float
74
+ *
75
+ * Returns the X coordinate of the left edge.
76
+ *
77
+ * @return [Float]
78
+ */
65
79
  static VALUE Rect_get_left(VALUE self) {
66
- return DBL2NUM(((Rect *) Get_Rect_Struct(self))->rect.position.x);
80
+ return DBL2NUM(((Rect*)Get_Rect_Struct(self))->rect.position.x);
67
81
  }
68
82
 
83
+ /* call-seq: top -> Float
84
+ *
85
+ * Returns the Y coordinate of the top edge.
86
+ *
87
+ * @return [Float]
88
+ */
69
89
  static VALUE Rect_get_top(VALUE self) {
70
- return DBL2NUM(((Rect *) Get_Rect_Struct(self))->rect.position.y);
90
+ return DBL2NUM(((Rect*)Get_Rect_Struct(self))->rect.position.y);
71
91
  }
72
92
 
93
+ /* call-seq: width -> Float
94
+ *
95
+ * Returns the width.
96
+ *
97
+ * @return [Float]
98
+ */
73
99
  static VALUE Rect_get_width(VALUE self) {
74
- return DBL2NUM(((Rect *) Get_Rect_Struct(self))->rect.size.x);
100
+ return DBL2NUM(((Rect*)Get_Rect_Struct(self))->rect.size.x);
75
101
  }
76
102
 
103
+ /* call-seq: height -> Float
104
+ *
105
+ * Returns the height.
106
+ *
107
+ * @return [Float]
108
+ */
77
109
  static VALUE Rect_get_height(VALUE self) {
78
- return DBL2NUM(((Rect *) Get_Rect_Struct(self))->rect.size.y);
110
+ return DBL2NUM(((Rect*)Get_Rect_Struct(self))->rect.size.y);
79
111
  }
80
112
 
113
+ /* call-seq:
114
+ * left=(value) -> Float
115
+ *
116
+ * Sets the X coordinate of the left edge.
117
+ *
118
+ * @return [Float] +value+
119
+ */
81
120
  static VALUE Rect_set_left(VALUE self, VALUE rb_value) {
82
- ((Rect *) Get_Rect_Struct(self))->rect.position.x = NUM2DBL(rb_value);
121
+ ((Rect*)Get_Rect_Struct(self))->rect.position.x = NUM2DBL(rb_value);
83
122
  return rb_value;
84
123
  }
85
124
 
125
+ /* call-seq:
126
+ * top=(value) -> Float
127
+ *
128
+ * Sets the Y coordinate of the top edge.
129
+ *
130
+ * @return [Float] +value+
131
+ */
86
132
  static VALUE Rect_set_top(VALUE self, VALUE rb_value) {
87
- ((Rect *) Get_Rect_Struct(self))->rect.position.y = NUM2DBL(rb_value);
133
+ ((Rect*)Get_Rect_Struct(self))->rect.position.y = NUM2DBL(rb_value);
88
134
  return rb_value;
89
135
  }
90
136
 
137
+ /* call-seq:
138
+ * width=(value) -> Float
139
+ *
140
+ * Sets the width.
141
+ *
142
+ * @return [Float] +value+
143
+ */
91
144
  static VALUE Rect_set_width(VALUE self, VALUE rb_value) {
92
- ((Rect *) Get_Rect_Struct(self))->rect.size.x = NUM2DBL(rb_value);
145
+ ((Rect*)Get_Rect_Struct(self))->rect.size.x = NUM2DBL(rb_value);
93
146
  return rb_value;
94
147
  }
95
148
 
149
+ /* call-seq:
150
+ * height=(value) -> Float
151
+ *
152
+ * Sets the height.
153
+ *
154
+ * @return [Float] +value+
155
+ */
96
156
  static VALUE Rect_set_height(VALUE self, VALUE rb_value) {
97
- ((Rect *) Get_Rect_Struct(self))->rect.size.y = NUM2DBL(rb_value);
157
+ ((Rect*)Get_Rect_Struct(self))->rect.size.y = NUM2DBL(rb_value);
98
158
  return rb_value;
99
159
  }
100
160
 
161
+ /* call-seq: position -> Vector2
162
+ *
163
+ * Returns the object's position.
164
+ *
165
+ * @return [Vector2] the +(left, top)+ corner
166
+ */
101
167
  static VALUE Rect_get_position(VALUE self) {
102
- sfFloatRect rect = ((Rect *) Get_Rect_Struct(self))->rect;
168
+ sfFloatRect rect = ((Rect*)Get_Rect_Struct(self))->rect;
103
169
 
104
170
  return vec2f_to_rb(rect.position);
105
171
  }
106
172
 
173
+ /* call-seq: size -> Vector2
174
+ *
175
+ * Returns the object's size.
176
+ *
177
+ * @return [Vector2] the +(width, height)+ dimensions
178
+ */
107
179
  static VALUE Rect_get_size(VALUE self) {
108
- sfFloatRect rect = ((Rect *) Get_Rect_Struct(self))->rect;
180
+ sfFloatRect rect = ((Rect*)Get_Rect_Struct(self))->rect;
109
181
 
110
182
  return vec2f_to_rb(rect.size);
111
183
  }
112
184
 
185
+ /* call-seq:
186
+ * position=(value) -> Vector2
187
+ *
188
+ * Sets the object's position.
189
+ *
190
+ * @return [Vector2] +value+
191
+ */
113
192
  static VALUE Rect_set_position(VALUE self, VALUE rb_position) {
114
- ((Rect *) Get_Rect_Struct(self))->rect.position = vec2f_from_rb(rb_position);
193
+ ((Rect*)Get_Rect_Struct(self))->rect.position = vec2f_from_rb(rb_position);
115
194
  return rb_position;
116
195
  }
117
196
 
197
+ /* call-seq:
198
+ * size=(value) -> Vector2
199
+ *
200
+ * Sets the object's size.
201
+ *
202
+ * @return [Vector2] +value+
203
+ */
118
204
  static VALUE Rect_set_size(VALUE self, VALUE rb_size) {
119
- ((Rect *) Get_Rect_Struct(self))->rect.size = vec2f_from_rb(rb_size);
205
+ ((Rect*)Get_Rect_Struct(self))->rect.size = vec2f_from_rb(rb_size);
120
206
  return rb_size;
121
207
  }
122
208
 
123
- static VALUE Rect_contains(int argc, VALUE *argv, VALUE self) {
124
- sfFloatRect rect = ((Rect *) Get_Rect_Struct(self))->rect;
209
+ /* call-seq:
210
+ * contains?(point) -> true or false
211
+ * contains?(x, y) -> true or false
212
+ *
213
+ * Returns +true+ if the rectangle contains the given point.
214
+ *
215
+ * @return [Boolean]
216
+ * @raise [ArgumentError] if given an argument count other than 1 or 2
217
+ */
218
+ static VALUE Rect_contains(int argc, VALUE* argv, VALUE self) {
219
+ sfFloatRect rect = ((Rect*)Get_Rect_Struct(self))->rect;
125
220
  sfVector2f point;
126
221
 
127
222
  if (argc == 1) {
128
223
  point = vec2f_from_rb(argv[0]);
129
224
  } else if (argc == 2) {
130
- point = (sfVector2f) {(float) NUM2DBL(argv[0]), (float) NUM2DBL(argv[1])};
225
+ point = (sfVector2f){(float)NUM2DBL(argv[0]), (float)NUM2DBL(argv[1])};
131
226
  } else {
132
227
  raise_invalid_arguments_excepted(2, argc);
133
228
  return Qfalse;
@@ -136,8 +231,16 @@ static VALUE Rect_contains(int argc, VALUE *argv, VALUE self) {
136
231
  return BOOL2RB(sfFloatRect_contains(&rect, point));
137
232
  }
138
233
 
234
+ /* call-seq:
235
+ * intersection(other) -> Rect or nil
236
+ *
237
+ * Returns the overlapping region of two rectangles.
238
+ *
239
+ * @return [Rect, nil] the overlapping region, or +nil+ if the rects don't
240
+ * intersect
241
+ */
139
242
  static VALUE Rect_intersection(VALUE self, VALUE rb_other) {
140
- sfFloatRect a = ((Rect *) Get_Rect_Struct(self))->rect;
243
+ sfFloatRect a = ((Rect*)Get_Rect_Struct(self))->rect;
141
244
  sfFloatRect b = rect_from_rb(rb_other);
142
245
  sfFloatRect intersection;
143
246
 
@@ -148,17 +251,36 @@ static VALUE Rect_intersection(VALUE self, VALUE rb_other) {
148
251
  return Qnil;
149
252
  }
150
253
 
254
+ /* call-seq:
255
+ * intersects?(other) -> true or false
256
+ *
257
+ * Returns +true+ if the two rectangles overlap.
258
+ *
259
+ * @return [Boolean]
260
+ */
151
261
  static VALUE Rect_intersects(VALUE self, VALUE rb_other) {
152
262
  return BOOL2RB(Rect_intersection(self, rb_other) != Qnil);
153
263
  }
154
264
 
265
+ /* call-seq: to_a -> [Float, Float, Float, Float]
266
+ *
267
+ * Returns the object as an Array.
268
+ *
269
+ * @return [Array<Float>] +[left, top, width, height]+
270
+ */
155
271
  static VALUE Rect_to_a(VALUE self) {
156
- sfFloatRect rect = ((Rect *) Get_Rect_Struct(self))->rect;
272
+ sfFloatRect rect = ((Rect*)Get_Rect_Struct(self))->rect;
157
273
 
158
274
  return rb_ary_new_from_args(4, DBL2NUM(rect.position.x), DBL2NUM(rect.position.y),
159
275
  DBL2NUM(rect.size.x), DBL2NUM(rect.size.y));
160
276
  }
161
277
 
278
+ /* call-seq: each { |component| ... } -> self
279
+ *
280
+ * Yields +left+, +top+, +width+, +height+ in that order.
281
+ *
282
+ * @return [self]
283
+ */
162
284
  static VALUE Rect_each(VALUE self) {
163
285
  VALUE array = Rect_to_a(self);
164
286
  long i;
@@ -170,12 +292,19 @@ static VALUE Rect_each(VALUE self) {
170
292
  return self;
171
293
  }
172
294
 
295
+ /* call-seq:
296
+ * self == other -> true or false
297
+ *
298
+ * +other+ may be a Rect or a 4-element Array.
299
+ *
300
+ * @return [Boolean]
301
+ */
173
302
  static VALUE Rect_eql(VALUE self, VALUE rb_other) {
174
- sfFloatRect a = ((Rect *) Get_Rect_Struct(self))->rect;
303
+ sfFloatRect a = ((Rect*)Get_Rect_Struct(self))->rect;
175
304
  sfFloatRect b;
176
305
 
177
306
  if (rb_obj_is_kind_of(rb_other, rb_cRect)) {
178
- b = ((Rect *) Get_Rect_Struct(rb_other))->rect;
307
+ b = ((Rect*)Get_Rect_Struct(rb_other))->rect;
179
308
  } else if (RB_TYPE_P(rb_other, T_ARRAY) && RARRAY_LEN(rb_other) >= 4) {
180
309
  b = rect_from_rb(rb_other);
181
310
  } else {
@@ -186,17 +315,50 @@ static VALUE Rect_eql(VALUE self, VALUE rb_other) {
186
315
  a.size.x == b.size.x && a.size.y == b.size.y);
187
316
  }
188
317
 
318
+ /* call-seq: to_s -> String
319
+ *
320
+ * Returns a human-readable representation of the object.
321
+ *
322
+ * @return [String] +"(left, top, width, height)"+
323
+ */
189
324
  static VALUE Rect_to_s(VALUE self) {
190
- sfFloatRect rect = ((Rect *) Get_Rect_Struct(self))->rect;
325
+ sfFloatRect rect = ((Rect*)Get_Rect_Struct(self))->rect;
191
326
  char buffer[96];
192
327
 
193
- snprintf(buffer, sizeof(buffer), "(%g, %g, %g, %g)", rect.position.x, rect.position.y, rect.size.x, rect.size.y);
328
+ snprintf(buffer, sizeof(buffer), "(%g, %g, %g, %g)", rect.position.x, rect.position.y,
329
+ rect.size.x, rect.size.y);
194
330
 
195
331
  return rb_str_new2(buffer);
196
332
  }
197
333
 
198
- void Init_Rect(VALUE rb_module) {
199
- rb_cRect = rb_define_class_under(rb_module, "Rect", rb_cObject);
334
+ /* Document-class: SFML::Rect
335
+ * An axis-aligned rectangle, stored as a position +(left, top)+ and a size
336
+ * +(width, height)+. Used both for float rects (bounds, viewports) and int
337
+ * rects (texture sub-regions) -- the underlying storage is always Float.
338
+ *
339
+ * Includes +Enumerable+ and behaves like a 4-element sequence.
340
+ *
341
+ * @!attribute left
342
+ * The X coordinate of the left edge.
343
+ * @return [Float] the X coordinate of the top-left corner
344
+ * @!attribute top
345
+ * The Y coordinate of the top edge.
346
+ * @return [Float] the Y coordinate of the top-left corner
347
+ * @!attribute width
348
+ * The width.
349
+ * @return [Float] the width
350
+ * @!attribute height
351
+ * The height.
352
+ * @return [Float] the height
353
+ * @!attribute position
354
+ * The object's position.
355
+ * @return [Vector2] the +(left, top)+ corner
356
+ * @!attribute size
357
+ * The object's size.
358
+ * @return [Vector2] the +(width, height)+ dimensions
359
+ */
360
+ void Init_Rect(VALUE rb_mSFML) {
361
+ rb_cRect = rb_define_class_under(rb_mSFML, "Rect", rb_cObject);
200
362
 
201
363
  rb_include_module(rb_cRect, rb_mEnumerable);
202
364
 
@@ -231,15 +393,15 @@ VALUE Get_Klass_Rect(void) {
231
393
  return rb_cRect;
232
394
  }
233
395
 
234
- void *Get_Rect_Struct(VALUE self) {
235
- Rect *ptr;
396
+ void* Get_Rect_Struct(VALUE self) {
397
+ Rect* ptr;
236
398
  TypedData_Get_Struct(self, Rect, &Rect_data_type, ptr);
237
399
  return ptr;
238
400
  }
239
401
 
240
402
  sfFloatRect rect_from_rb(VALUE rb_rect) {
241
403
  if (rb_obj_is_kind_of(rb_rect, rb_cRect)) {
242
- return ((Rect *) Get_Rect_Struct(rb_rect))->rect;
404
+ return ((Rect*)Get_Rect_Struct(rb_rect))->rect;
243
405
  }
244
406
 
245
407
  if (RB_TYPE_P(rb_rect, T_ARRAY)) {
@@ -247,15 +409,14 @@ sfFloatRect rect_from_rb(VALUE rb_rect) {
247
409
  raise_invalid_array_length(4);
248
410
  }
249
411
 
250
- return (sfFloatRect) {
251
- {(float) NUM2DBL(rb_ary_entry(rb_rect, 0)), (float) NUM2DBL(rb_ary_entry(rb_rect, 1))},
252
- {(float) NUM2DBL(rb_ary_entry(rb_rect, 2)), (float) NUM2DBL(rb_ary_entry(rb_rect, 3))}
253
- };
412
+ return (sfFloatRect){
413
+ {(float)NUM2DBL(rb_ary_entry(rb_rect, 0)), (float)NUM2DBL(rb_ary_entry(rb_rect, 1))},
414
+ {(float)NUM2DBL(rb_ary_entry(rb_rect, 2)), (float)NUM2DBL(rb_ary_entry(rb_rect, 3))}};
254
415
  }
255
416
 
256
417
  raise_invalid_argument_class(rb_cRect);
257
418
 
258
- return (sfFloatRect) {{0, 0}, {0, 0}};
419
+ return (sfFloatRect){{0, 0}, {0, 0}};
259
420
  }
260
421
 
261
422
  VALUE rect_to_rb(sfFloatRect c_rect) {
@@ -265,17 +426,13 @@ VALUE rect_to_rb(sfFloatRect c_rect) {
265
426
  sfIntRect int_rect_from_rb(VALUE rb_rect) {
266
427
  sfFloatRect rect = rect_from_rb(rb_rect);
267
428
 
268
- return (sfIntRect) {
269
- {(int) rect.position.x, (int) rect.position.y},
270
- {(int) rect.size.x, (int) rect.size.y}
271
- };
429
+ return (sfIntRect){{(int)rect.position.x, (int)rect.position.y},
430
+ {(int)rect.size.x, (int)rect.size.y}};
272
431
  }
273
432
 
274
433
  VALUE int_rect_to_rb(sfIntRect c_rect) {
275
- return Rect_wrap((sfFloatRect) {
276
- {(float) c_rect.position.x, (float) c_rect.position.y},
277
- {(float) c_rect.size.x, (float) c_rect.size.y}
278
- });
434
+ return Rect_wrap((sfFloatRect){{(float)c_rect.position.x, (float)c_rect.position.y},
435
+ {(float)c_rect.size.x, (float)c_rect.size.y}});
279
436
  }
280
437
 
281
438
  void Rect_check(VALUE rb_rect) {