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,41 @@
15
15
  #include "core/macros.h"
16
16
 
17
17
  typedef struct {
18
- sfSprite *sprite;
18
+ sfSprite* sprite;
19
19
  VALUE rb_texture;
20
20
  } Sprite;
21
21
 
22
22
  static VALUE rb_cSprite;
23
23
 
24
- static void Sprite_mark(void *ptr) {
25
- rb_gc_mark(((Sprite *) ptr)->rb_texture);
24
+ static void Sprite_mark(void* ptr) {
25
+ rb_gc_mark(((Sprite*)ptr)->rb_texture);
26
26
  }
27
27
 
28
- static void Sprite_free(void *ptr) {
29
- sfSprite_destroy(((Sprite *) ptr)->sprite);
28
+ static void Sprite_free(void* ptr) {
29
+ if (((Sprite*)ptr)->sprite != NULL) {
30
+ sfSprite_destroy(((Sprite*)ptr)->sprite);
31
+ }
32
+
30
33
  free(ptr);
31
34
  }
32
35
 
33
36
  static const rb_data_type_t Sprite_data_type = {
34
37
  .wrap_struct_name = "SFML::Sprite",
35
38
  .function = {.dmark = Sprite_mark, .dfree = Sprite_free, .dsize = NULL},
36
- .flags = RUBY_TYPED_FREE_IMMEDIATELY
37
- };
39
+ .flags = RUBY_TYPED_FREE_IMMEDIATELY};
38
40
 
39
- static Sprite *Get_Sprite(VALUE self) {
40
- Sprite *ptr;
41
+ static Sprite* Get_Sprite(VALUE self) {
42
+ Sprite* ptr;
41
43
  TypedData_Get_Struct(self, Sprite, &Sprite_data_type, ptr);
42
44
  return ptr;
43
45
  }
44
46
 
45
- static sfSprite *Get_Sprite_Struct(VALUE self) {
47
+ static sfSprite* Get_Sprite_Struct(VALUE self) {
46
48
  return Get_Sprite(self)->sprite;
47
49
  }
48
50
 
49
- static VALUE Sprite_wrap(VALUE klass, sfSprite *sprite) {
50
- Sprite *ptr;
51
+ static VALUE Sprite_wrap(VALUE klass, sfSprite* sprite) {
52
+ Sprite* ptr;
51
53
 
52
54
  if (sprite == NULL) {
53
55
  rb_raise(rb_eRuntimeError, "failed to create sprite");
@@ -60,33 +62,75 @@ static VALUE Sprite_wrap(VALUE klass, sfSprite *sprite) {
60
62
  return TypedData_Wrap_Struct(klass, &Sprite_data_type, ptr);
61
63
  }
62
64
 
63
- static VALUE Sprite_new(int argc, VALUE *argv, VALUE klass) {
64
- VALUE rb_texture, self;
65
- Sprite *ptr;
65
+ static VALUE Sprite_initialize_copy(VALUE self, VALUE other) {
66
+ (void)other;
67
+ rb_raise(rb_eTypeError, "can't copy a %s", rb_obj_classname(self));
68
+ }
69
+
70
+ static VALUE Sprite_alloc(VALUE klass) {
71
+ Sprite* ptr = malloc(sizeof(Sprite));
72
+
73
+ if (ptr == NULL) {
74
+ rb_raise(rb_eNoMemError, "failed to allocate sprite");
75
+ }
76
+
77
+ ptr->sprite = NULL;
78
+ ptr->rb_texture = Qnil;
66
79
 
67
- rb_scan_args(argc, argv, "01", &rb_texture);
80
+ return TypedData_Wrap_Struct(klass, &Sprite_data_type, ptr);
81
+ }
68
82
 
69
- if (!NIL_P(rb_texture) && !rb_obj_is_kind_of(rb_texture, Get_Klass_Texture())) {
83
+ /* call-seq:
84
+ * Sprite.new(texture) -> Sprite
85
+ *
86
+ * CSFML requires a texture at creation time -- its C API unconditionally
87
+ * dereferences a NULL texture argument rather than tolerating one, so unlike
88
+ * most other constructors here, the texture is not optional.
89
+ *
90
+ * @return [Sprite]
91
+ * @raise [ArgumentError] if +texture+ is not a Texture
92
+ */
93
+ static VALUE Sprite_initialize(VALUE self, VALUE rb_texture) {
94
+ Sprite* ptr;
95
+
96
+ if (!rb_obj_is_kind_of(rb_texture, Get_Klass_Texture())) {
70
97
  raise_invalid_argument_class(Get_Klass_Texture());
71
98
  }
72
99
 
73
- ptr = malloc(sizeof(Sprite));
74
- ptr->sprite = sfSprite_create(NIL_P(rb_texture) ? NULL : Get_Texture_Struct(rb_texture));
75
- ptr->rb_texture = NIL_P(rb_texture) ? Qnil : rb_texture;
100
+ TypedData_Get_Struct(self, Sprite, &Sprite_data_type, ptr);
76
101
 
77
- self = TypedData_Wrap_Struct(klass, &Sprite_data_type, ptr);
102
+ ptr->sprite = sfSprite_create(Get_Texture_Struct(rb_texture));
103
+ ptr->rb_texture = rb_texture;
104
+
105
+ if (ptr->sprite == NULL) {
106
+ rb_raise(rb_eRuntimeError, "failed to create sprite");
107
+ }
78
108
 
79
109
  return self;
80
110
  }
81
111
 
112
+ /* call-seq: copy -> Sprite
113
+ *
114
+ * Returns a deep copy of the object.
115
+ *
116
+ * @return [Sprite] an independent copy
117
+ */
82
118
  static VALUE Sprite_copy(VALUE self) {
83
- Sprite *ptr = Get_Sprite(self);
119
+ Sprite* ptr = Get_Sprite(self);
84
120
 
85
121
  return Sprite_wrap(Get_Klass_Sprite(), sfSprite_copy(ptr->sprite));
86
122
  }
87
123
 
124
+ /* call-seq:
125
+ * texture=(value) -> Texture or nil
126
+ *
127
+ * Sets the object's texture.
128
+ *
129
+ * @return [Texture, nil] +value+
130
+ * @raise [TypeError] if +value+ is neither nil nor a Texture
131
+ */
88
132
  static VALUE Sprite_set_texture(VALUE self, VALUE rb_texture) {
89
- Sprite *ptr = Get_Sprite(self);
133
+ Sprite* ptr = Get_Sprite(self);
90
134
 
91
135
  if (NIL_P(rb_texture)) {
92
136
  ptr->rb_texture = Qnil;
@@ -104,116 +148,287 @@ static VALUE Sprite_set_texture(VALUE self, VALUE rb_texture) {
104
148
  return rb_texture;
105
149
  }
106
150
 
151
+ /* call-seq: texture -> Texture or nil
152
+ *
153
+ * Returns the object's texture, or +nil+ if it has none.
154
+ *
155
+ * @return [Texture, nil]
156
+ */
107
157
  static VALUE Sprite_get_texture(VALUE self) {
108
158
  return Get_Sprite(self)->rb_texture;
109
159
  }
110
160
 
161
+ /* call-seq: texture_rect -> Rect
162
+ *
163
+ * Returns the sub-rectangle of the texture displayed on the object.
164
+ *
165
+ * @return [Rect] the sub-rectangle of the texture that gets displayed
166
+ */
111
167
  static VALUE Sprite_get_texture_rect(VALUE self) {
112
168
  return int_rect_to_rb(sfSprite_getTextureRect(Get_Sprite_Struct(self)));
113
169
  }
114
170
 
171
+ /* call-seq:
172
+ * texture_rect=(value) -> Rect
173
+ *
174
+ * Sets the sub-rectangle of the texture displayed on the object.
175
+ *
176
+ * @return [Rect] +value+
177
+ */
115
178
  static VALUE Sprite_set_texture_rect(VALUE self, VALUE rb_rect) {
116
179
  sfSprite_setTextureRect(Get_Sprite_Struct(self), int_rect_from_rb(rb_rect));
117
180
  return rb_rect;
118
181
  }
119
182
 
183
+ /* call-seq: color -> Color
184
+ *
185
+ * Returns the object's color.
186
+ *
187
+ * @return [Color] the tint color multiplied with the texture's pixels
188
+ */
120
189
  static VALUE Sprite_get_color(VALUE self) {
121
190
  return color_to_rb(sfSprite_getColor(Get_Sprite_Struct(self)));
122
191
  }
123
192
 
193
+ /* call-seq:
194
+ * color=(value) -> Color
195
+ *
196
+ * Sets the object's color.
197
+ *
198
+ * @return [Color] +value+
199
+ */
124
200
  static VALUE Sprite_set_color(VALUE self, VALUE rb_color) {
125
201
  sfSprite_setColor(Get_Sprite_Struct(self), color_from_rb(rb_color));
126
202
  return rb_color;
127
203
  }
128
204
 
205
+ /* call-seq: position -> Vector2
206
+ *
207
+ * Returns the object's position.
208
+ *
209
+ * @return [Vector2]
210
+ */
129
211
  static VALUE Sprite_get_position(VALUE self) {
130
212
  return vec2f_to_rb(sfSprite_getPosition(Get_Sprite_Struct(self)));
131
213
  }
132
214
 
215
+ /* call-seq:
216
+ * position=(value) -> Vector2
217
+ *
218
+ * Sets the object's position.
219
+ *
220
+ * @return [Vector2] +value+
221
+ */
133
222
  static VALUE Sprite_set_position(VALUE self, VALUE rb_position) {
134
223
  sfSprite_setPosition(Get_Sprite_Struct(self), vec2f_from_rb(rb_position));
135
224
  return rb_position;
136
225
  }
137
226
 
227
+ /* call-seq: rotation -> Float
228
+ *
229
+ * Returns the object's rotation, in degrees.
230
+ *
231
+ * @return [Float] degrees
232
+ */
138
233
  static VALUE Sprite_get_rotation(VALUE self) {
139
234
  return DBL2NUM(sfSprite_getRotation(Get_Sprite_Struct(self)));
140
235
  }
141
236
 
237
+ /* call-seq:
238
+ * rotation=(value) -> Float
239
+ *
240
+ * Sets the object's rotation, in degrees.
241
+ *
242
+ * @return [Float] +value+
243
+ */
142
244
  static VALUE Sprite_set_rotation(VALUE self, VALUE rb_rotation) {
143
245
  sfSprite_setRotation(Get_Sprite_Struct(self), NUM2DBL(rb_rotation));
144
246
  return rb_rotation;
145
247
  }
146
248
 
249
+ /* call-seq: scale -> Vector2
250
+ *
251
+ * Returns the object's scale factors.
252
+ *
253
+ * @return [Vector2]
254
+ */
147
255
  static VALUE Sprite_get_scale(VALUE self) {
148
256
  return vec2f_to_rb(sfSprite_getScale(Get_Sprite_Struct(self)));
149
257
  }
150
258
 
259
+ /* call-seq:
260
+ * scale=(value) -> Vector2
261
+ *
262
+ * Sets the object's scale factors.
263
+ *
264
+ * @return [Vector2] +value+
265
+ */
151
266
  static VALUE Sprite_set_scale(VALUE self, VALUE rb_scale) {
152
267
  sfSprite_setScale(Get_Sprite_Struct(self), vec2f_from_rb(rb_scale));
153
268
  return rb_scale;
154
269
  }
155
270
 
271
+ /* call-seq: origin -> Vector2
272
+ *
273
+ * Returns the object's origin.
274
+ *
275
+ * @return [Vector2]
276
+ */
156
277
  static VALUE Sprite_get_origin(VALUE self) {
157
278
  return vec2f_to_rb(sfSprite_getOrigin(Get_Sprite_Struct(self)));
158
279
  }
159
280
 
281
+ /* call-seq:
282
+ * origin=(value) -> Vector2
283
+ *
284
+ * Sets the object's origin.
285
+ *
286
+ * @return [Vector2] +value+
287
+ */
160
288
  static VALUE Sprite_set_origin(VALUE self, VALUE rb_origin) {
161
289
  sfSprite_setOrigin(Get_Sprite_Struct(self), vec2f_from_rb(rb_origin));
162
290
  return rb_origin;
163
291
  }
164
292
 
293
+ /* call-seq:
294
+ * move(offset) -> self
295
+ *
296
+ * Moves the object by +offset+.
297
+ *
298
+ * @return [self]
299
+ */
165
300
  static VALUE Sprite_move(VALUE self, VALUE rb_offset) {
166
301
  sfSprite_move(Get_Sprite_Struct(self), vec2f_from_rb(rb_offset));
167
302
  return self;
168
303
  }
169
304
 
305
+ /* call-seq:
306
+ * rotate(angle) -> self
307
+ *
308
+ * Rotates the object by +angle+ degrees.
309
+ *
310
+ * @return [self]
311
+ */
170
312
  static VALUE Sprite_rotate(VALUE self, VALUE rb_angle) {
171
313
  sfSprite_rotate(Get_Sprite_Struct(self), NUM2DBL(rb_angle));
172
314
  return self;
173
315
  }
174
316
 
317
+ /* call-seq:
318
+ * scale!(factors) -> self
319
+ *
320
+ * Scales the object by +factors+ relative to its current scale.
321
+ *
322
+ * @return [self]
323
+ */
175
324
  static VALUE Sprite_scale(VALUE self, VALUE rb_factors) {
176
325
  sfSprite_scale(Get_Sprite_Struct(self), vec2f_from_rb(rb_factors));
177
326
  return self;
178
327
  }
179
328
 
329
+ /* call-seq: transform -> Array<Float>
330
+ *
331
+ * Returns the object's 3x3 row-major transform matrix.
332
+ *
333
+ * @return [Array<Float>] the 9-element matrix (also available as #matrix)
334
+ */
180
335
  static VALUE Sprite_get_transform(VALUE self) {
181
336
  return Transform_MatrixToArray(sfSprite_getTransform(Get_Sprite_Struct(self)).matrix);
182
337
  }
183
338
 
339
+ /* call-seq: inverse_transform -> Array<Float>
340
+ *
341
+ * Returns the 3x3 row-major inverse of the object's transform matrix.
342
+ *
343
+ * @return [Array<Float>] the inverse of #transform
344
+ */
184
345
  static VALUE Sprite_get_inverse_transform(VALUE self) {
185
346
  return Transform_MatrixToArray(sfSprite_getInverseTransform(Get_Sprite_Struct(self)).matrix);
186
347
  }
187
348
 
349
+ /* call-seq: local_bounds -> Rect
350
+ *
351
+ * Returns the bounding box in local (untransformed) coordinates.
352
+ *
353
+ * @return [Rect] the bounding box in local coordinates, before any
354
+ * transform is applied
355
+ */
188
356
  static VALUE Sprite_get_local_bounds(VALUE self) {
189
357
  return rect_to_rb(sfSprite_getLocalBounds(Get_Sprite_Struct(self)));
190
358
  }
191
359
 
360
+ /* call-seq: global_bounds -> Rect
361
+ *
362
+ * Returns the bounding box after the transform is applied.
363
+ *
364
+ * @return [Rect] the bounding box in the parent's coordinate system, after
365
+ * the current transform is applied
366
+ */
192
367
  static VALUE Sprite_get_global_bounds(VALUE self) {
193
368
  return rect_to_rb(sfSprite_getGlobalBounds(Get_Sprite_Struct(self)));
194
369
  }
195
370
 
371
+ /* call-seq:
372
+ * draw(target, state) -> nil
373
+ *
374
+ * Part of the Drawable interface; call Target#draw instead of this
375
+ * directly.
376
+ *
377
+ * @return [nil]
378
+ * @raise [TypeError] if +target+ is not a Target or +state+ is not a
379
+ * RenderState
380
+ */
196
381
  static VALUE Sprite_draw(VALUE self, VALUE rb_target, VALUE rb_state) {
197
- if (!rb_obj_is_kind_of(rb_target, Get_Klass_Target())) {
198
- raise_invalid_argument_class(Get_Klass_Target());
199
- }
382
+ TargetView view = Get_RenderTarget_View(rb_target);
200
383
 
201
384
  if (!rb_obj_is_kind_of(rb_state, Get_Klass_RenderState())) {
202
385
  raise_invalid_argument_class(Get_Klass_RenderState());
203
386
  }
204
387
 
205
- TARGET_DRAW(Get_Target_Struct(rb_target), sfRenderWindow_drawSprite, sfRenderTexture_drawSprite,
388
+ TARGET_DRAW(view, sfRenderWindow_drawSprite, sfRenderTexture_drawSprite,
206
389
  Get_Sprite_Struct(self), Get_RenderState_Struct(rb_state));
207
390
 
208
391
  return Qnil;
209
392
  }
210
393
 
211
- void Init_Sprite(VALUE rb_module) {
212
- rb_cSprite = rb_define_class_under(rb_module, "Sprite", rb_cObject);
394
+ /* Document-class: SFML::Sprite
395
+ * A drawable representation of a Texture (or a sub-rectangle of one),
396
+ * positioned, rotated, scaled and tinted like any other Transformable
397
+ * object.
398
+ *
399
+ * Includes +Drawable+.
400
+ *
401
+ * @!attribute texture
402
+ * The object's texture, or +nil+ if it has none.
403
+ * @return [Texture, nil]
404
+ * @!attribute texture_rect
405
+ * The sub-rectangle of the texture displayed on the object.
406
+ * @return [Rect]
407
+ * @!attribute color
408
+ * The object's color.
409
+ * @return [Color]
410
+ * @!attribute position
411
+ * The object's position.
412
+ * @return [Vector2]
413
+ * @!attribute rotation
414
+ * The object's rotation, in degrees.
415
+ * @return [Float] degrees
416
+ * @!attribute scale
417
+ * The object's scale factors.
418
+ * @return [Vector2]
419
+ * @!attribute origin
420
+ * The object's origin.
421
+ * @return [Vector2]
422
+ */
423
+ void Init_Sprite(VALUE rb_mSFML) {
424
+ rb_cSprite = rb_define_class_under(rb_mSFML, "Sprite", rb_cObject);
425
+
426
+ rb_define_alloc_func(rb_cSprite, Sprite_alloc);
213
427
 
214
428
  rb_include_module(rb_cSprite, Get_Module_Drawable());
215
429
 
216
- rb_define_singleton_method(rb_cSprite, "new", Sprite_new, -1);
430
+ rb_define_method(rb_cSprite, "initialize", Sprite_initialize, 1);
431
+ rb_define_private_method(rb_cSprite, "initialize_copy", Sprite_initialize_copy, 1);
217
432
 
218
433
  rb_define_method(rb_cSprite, "copy", Sprite_copy, 0);
219
434