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
data/ext/graphics/text.c CHANGED
@@ -28,7 +28,10 @@ static void Text_mark(void* ptr) {
28
28
  }
29
29
 
30
30
  static void Text_free(void* ptr) {
31
- sfText_destroy(((Text*)ptr)->text);
31
+ if (((Text*)ptr)->text != NULL) {
32
+ sfText_destroy(((Text*)ptr)->text);
33
+ }
34
+
32
35
  free(ptr);
33
36
  }
34
37
 
@@ -61,27 +64,55 @@ static VALUE Text_wrap(VALUE klass, sfText* text) {
61
64
  return TypedData_Wrap_Struct(klass, &Text_data_type, ptr);
62
65
  }
63
66
 
64
- static VALUE Text_new(int argc, VALUE* argv, VALUE klass) {
65
- VALUE rb_font, rb_string, rb_size, self;
67
+ static VALUE Text_initialize_copy(VALUE self, VALUE other) {
68
+ (void)other;
69
+ rb_raise(rb_eTypeError, "can't copy a %s", rb_obj_classname(self));
70
+ }
71
+
72
+ static VALUE Text_alloc(VALUE klass) {
73
+ Text* ptr = malloc(sizeof(Text));
74
+
75
+ if (ptr == NULL) {
76
+ rb_raise(rb_eNoMemError, "failed to allocate text");
77
+ }
78
+
79
+ ptr->text = NULL;
80
+ ptr->rb_font = Qnil;
81
+
82
+ return TypedData_Wrap_Struct(klass, &Text_data_type, ptr);
83
+ }
84
+
85
+ /* call-seq:
86
+ * Text.new(font) -> Text
87
+ * Text.new(font, string) -> Text
88
+ * Text.new(font, string, character_size) -> Text
89
+ *
90
+ * CSFML requires a font at creation time -- its C API unconditionally
91
+ * dereferences a NULL font argument rather than tolerating one, so unlike
92
+ * most other constructors here, the font is not optional.
93
+ *
94
+ * @return [Text]
95
+ * @raise [ArgumentError] if +font+ is not a Font
96
+ */
97
+ static VALUE Text_initialize(int argc, VALUE* argv, VALUE self) {
98
+ VALUE rb_font, rb_string, rb_size;
66
99
  Text* ptr;
67
100
 
68
- rb_scan_args(argc, argv, "03", &rb_font, &rb_string, &rb_size);
101
+ rb_scan_args(argc, argv, "12", &rb_font, &rb_string, &rb_size);
69
102
 
70
- if (!NIL_P(rb_font) && !rb_obj_is_kind_of(rb_font, Get_Klass_Font())) {
103
+ if (!rb_obj_is_kind_of(rb_font, Get_Klass_Font())) {
71
104
  raise_invalid_argument_class(Get_Klass_Font());
72
105
  }
73
106
 
74
- ptr = malloc(sizeof(Text));
75
- ptr->text = sfText_create(NIL_P(rb_font) ? NULL : Get_Font_Struct(rb_font));
76
- ptr->rb_font = NIL_P(rb_font) ? Qnil : rb_font;
107
+ TypedData_Get_Struct(self, Text, &Text_data_type, ptr);
108
+
109
+ ptr->text = sfText_create(Get_Font_Struct(rb_font));
110
+ ptr->rb_font = rb_font;
77
111
 
78
112
  if (ptr->text == NULL) {
79
- free(ptr);
80
113
  rb_raise(rb_eRuntimeError, "failed to create text");
81
114
  }
82
115
 
83
- self = TypedData_Wrap_Struct(klass, &Text_data_type, ptr);
84
-
85
116
  if (!NIL_P(rb_string)) {
86
117
  sfText_setString(ptr->text, StringValueCStr(rb_string));
87
118
  }
@@ -93,6 +124,12 @@ static VALUE Text_new(int argc, VALUE* argv, VALUE klass) {
93
124
  return self;
94
125
  }
95
126
 
127
+ /* call-seq: copy -> Text
128
+ *
129
+ * Returns a deep copy of the object.
130
+ *
131
+ * @return [Text] an independent copy
132
+ */
96
133
  static VALUE Text_copy(VALUE self) {
97
134
  Text* ptr = Get_Text(self);
98
135
  VALUE copy = Text_wrap(Get_Klass_Text(), sfText_copy(ptr->text));
@@ -103,6 +140,14 @@ static VALUE Text_copy(VALUE self) {
103
140
  return copy;
104
141
  }
105
142
 
143
+ /* call-seq:
144
+ * font=(value) -> Font or nil
145
+ *
146
+ * Sets the text's font.
147
+ *
148
+ * @return [Font, nil] +value+
149
+ * @raise [TypeError] if +value+ is neither nil nor a Font
150
+ */
106
151
  static VALUE Text_set_font(VALUE self, VALUE rb_font) {
107
152
  Text* ptr = Get_Text(self);
108
153
 
@@ -122,12 +167,25 @@ static VALUE Text_set_font(VALUE self, VALUE rb_font) {
122
167
  return rb_font;
123
168
  }
124
169
 
170
+ /* call-seq: font -> Font or nil
171
+ *
172
+ * Returns the text's font.
173
+ *
174
+ * @return [Font, nil]
175
+ */
125
176
  static VALUE Text_get_font(VALUE self) {
126
177
  return Get_Text(self)->rb_font;
127
178
  }
128
179
 
129
180
  /* Through the UTF-32 entry points, not sfText_setString: that one decodes the
130
181
  bytes with the C locale and mangles anything outside ASCII. */
182
+ /* call-seq:
183
+ * string=(value) -> String
184
+ *
185
+ * Sets the displayed string.
186
+ *
187
+ * @return [String] +value+
188
+ */
131
189
  static VALUE Text_set_string(VALUE self, VALUE rb_string) {
132
190
  VALUE buffer = utf32_from_rb(rb_string);
133
191
 
@@ -138,165 +196,427 @@ static VALUE Text_set_string(VALUE self, VALUE rb_string) {
138
196
  return rb_string;
139
197
  }
140
198
 
199
+ /* call-seq: string -> String
200
+ *
201
+ * Returns the displayed string.
202
+ *
203
+ * @return [String]
204
+ */
141
205
  static VALUE Text_get_string(VALUE self) {
142
206
  return utf32_to_rb(sfText_getUnicodeString(Get_Text_Struct(self)));
143
207
  }
144
208
 
209
+ /* call-seq:
210
+ * character_size=(value) -> Integer
211
+ *
212
+ * Sets the character size in pixels.
213
+ *
214
+ * @return [Integer] +value+
215
+ */
145
216
  static VALUE Text_set_character_size(VALUE self, VALUE rb_size) {
146
217
  sfText_setCharacterSize(Get_Text_Struct(self), (unsigned int)NUM2UINT(rb_size));
147
218
  return rb_size;
148
219
  }
149
220
 
221
+ /* call-seq: character_size -> Integer
222
+ *
223
+ * Returns the character size in pixels.
224
+ *
225
+ * @return [Integer] in pixels
226
+ */
150
227
  static VALUE Text_get_character_size(VALUE self) {
151
228
  return UINT2NUM(sfText_getCharacterSize(Get_Text_Struct(self)));
152
229
  }
153
230
 
231
+ /* call-seq:
232
+ * style=(value) -> Integer or Symbol
233
+ *
234
+ * Accepts either a single style Symbol/Integer, or an Array of them, which
235
+ * are OR-ed together.
236
+ *
237
+ * @return [Integer, Symbol] +value+
238
+ */
154
239
  static VALUE Text_set_style(VALUE self, VALUE rb_style) {
155
240
  sfText_setStyle(Get_Text_Struct(self), text_style_from_rb(rb_style));
156
241
  return rb_style;
157
242
  }
158
243
 
244
+ /* call-seq: style -> Integer
245
+ *
246
+ * Returns the text style flags.
247
+ *
248
+ * @return [Integer] a bitmask of the active style flags
249
+ */
159
250
  static VALUE Text_get_style(VALUE self) {
160
251
  return text_style_to_rb(sfText_getStyle(Get_Text_Struct(self)));
161
252
  }
162
253
 
254
+ /* call-seq: fill_color -> Color
255
+ *
256
+ * Returns the shape's fill color.
257
+ *
258
+ * @return [Color]
259
+ */
163
260
  static VALUE Text_get_fill_color(VALUE self) {
164
261
  return color_to_rb(sfText_getFillColor(Get_Text_Struct(self)));
165
262
  }
166
263
 
264
+ /* call-seq:
265
+ * fill_color=(value) -> Color
266
+ *
267
+ * Sets the shape's fill color.
268
+ *
269
+ * @return [Color] +value+
270
+ */
167
271
  static VALUE Text_set_fill_color(VALUE self, VALUE rb_color) {
168
272
  sfText_setFillColor(Get_Text_Struct(self), color_from_rb(rb_color));
169
273
  return rb_color;
170
274
  }
171
275
 
276
+ /* call-seq: outline_color -> Color
277
+ *
278
+ * Returns the shape's outline color.
279
+ *
280
+ * @return [Color]
281
+ */
172
282
  static VALUE Text_get_outline_color(VALUE self) {
173
283
  return color_to_rb(sfText_getOutlineColor(Get_Text_Struct(self)));
174
284
  }
175
285
 
286
+ /* call-seq:
287
+ * outline_color=(value) -> Color
288
+ *
289
+ * Sets the shape's outline color.
290
+ *
291
+ * @return [Color] +value+
292
+ */
176
293
  static VALUE Text_set_outline_color(VALUE self, VALUE rb_color) {
177
294
  sfText_setOutlineColor(Get_Text_Struct(self), color_from_rb(rb_color));
178
295
  return rb_color;
179
296
  }
180
297
 
298
+ /* call-seq: outline_thickness -> Float
299
+ *
300
+ * Returns the shape's outline thickness.
301
+ *
302
+ * @return [Float]
303
+ */
181
304
  static VALUE Text_get_outline_thickness(VALUE self) {
182
305
  return DBL2NUM(sfText_getOutlineThickness(Get_Text_Struct(self)));
183
306
  }
184
307
 
308
+ /* call-seq:
309
+ * outline_thickness=(value) -> Float
310
+ *
311
+ * Sets the shape's outline thickness.
312
+ *
313
+ * @return [Float] +value+
314
+ */
185
315
  static VALUE Text_set_outline_thickness(VALUE self, VALUE rb_thickness) {
186
316
  sfText_setOutlineThickness(Get_Text_Struct(self), NUM2DBL(rb_thickness));
187
317
  return rb_thickness;
188
318
  }
189
319
 
320
+ /* call-seq: letter_spacing -> Float
321
+ *
322
+ * Returns the spacing between letters.
323
+ *
324
+ * @return [Float] a multiplier of the font's default spacing (1.0 = default)
325
+ */
190
326
  static VALUE Text_get_letter_spacing(VALUE self) {
191
327
  return DBL2NUM(sfText_getLetterSpacing(Get_Text_Struct(self)));
192
328
  }
193
329
 
330
+ /* call-seq:
331
+ * letter_spacing=(value) -> Float
332
+ *
333
+ * Sets the spacing between letters.
334
+ *
335
+ * @return [Float] +value+
336
+ */
194
337
  static VALUE Text_set_letter_spacing(VALUE self, VALUE rb_spacing) {
195
338
  sfText_setLetterSpacing(Get_Text_Struct(self), NUM2DBL(rb_spacing));
196
339
  return rb_spacing;
197
340
  }
198
341
 
342
+ /* call-seq: line_spacing -> Float
343
+ *
344
+ * Returns the line spacing multiplier.
345
+ *
346
+ * @return [Float] a multiplier of the font's default line spacing
347
+ */
199
348
  static VALUE Text_get_line_spacing(VALUE self) {
200
349
  return DBL2NUM(sfText_getLineSpacing(Get_Text_Struct(self)));
201
350
  }
202
351
 
352
+ /* call-seq:
353
+ * line_spacing=(value) -> Float
354
+ *
355
+ * Sets the spacing between lines.
356
+ *
357
+ * @return [Float] +value+
358
+ */
203
359
  static VALUE Text_set_line_spacing(VALUE self, VALUE rb_spacing) {
204
360
  sfText_setLineSpacing(Get_Text_Struct(self), NUM2DBL(rb_spacing));
205
361
  return rb_spacing;
206
362
  }
207
363
 
364
+ /* call-seq: position -> Vector2
365
+ *
366
+ * Returns the object's position.
367
+ *
368
+ * @return [Vector2]
369
+ */
208
370
  static VALUE Text_get_position(VALUE self) {
209
371
  return vec2f_to_rb(sfText_getPosition(Get_Text_Struct(self)));
210
372
  }
211
373
 
374
+ /* call-seq:
375
+ * position=(value) -> Vector2
376
+ *
377
+ * Sets the object's position.
378
+ *
379
+ * @return [Vector2] +value+
380
+ */
212
381
  static VALUE Text_set_position(VALUE self, VALUE rb_position) {
213
382
  sfText_setPosition(Get_Text_Struct(self), vec2f_from_rb(rb_position));
214
383
  return rb_position;
215
384
  }
216
385
 
386
+ /* call-seq: rotation -> Float
387
+ *
388
+ * Returns the object's rotation, in degrees.
389
+ *
390
+ * @return [Float] degrees
391
+ */
217
392
  static VALUE Text_get_rotation(VALUE self) {
218
393
  return DBL2NUM(sfText_getRotation(Get_Text_Struct(self)));
219
394
  }
220
395
 
396
+ /* call-seq:
397
+ * rotation=(value) -> Float
398
+ *
399
+ * Sets the object's rotation, in degrees.
400
+ *
401
+ * @return [Float] +value+
402
+ */
221
403
  static VALUE Text_set_rotation(VALUE self, VALUE rb_rotation) {
222
404
  sfText_setRotation(Get_Text_Struct(self), NUM2DBL(rb_rotation));
223
405
  return rb_rotation;
224
406
  }
225
407
 
408
+ /* call-seq: scale -> Vector2
409
+ *
410
+ * Returns the object's scale factors.
411
+ *
412
+ * @return [Vector2]
413
+ */
226
414
  static VALUE Text_get_scale(VALUE self) {
227
415
  return vec2f_to_rb(sfText_getScale(Get_Text_Struct(self)));
228
416
  }
229
417
 
418
+ /* call-seq:
419
+ * scale=(value) -> Vector2
420
+ *
421
+ * Sets the object's scale factors.
422
+ *
423
+ * @return [Vector2] +value+
424
+ */
230
425
  static VALUE Text_set_scale(VALUE self, VALUE rb_scale) {
231
426
  sfText_setScale(Get_Text_Struct(self), vec2f_from_rb(rb_scale));
232
427
  return rb_scale;
233
428
  }
234
429
 
430
+ /* call-seq: origin -> Vector2
431
+ *
432
+ * Returns the object's origin.
433
+ *
434
+ * @return [Vector2]
435
+ */
235
436
  static VALUE Text_get_origin(VALUE self) {
236
437
  return vec2f_to_rb(sfText_getOrigin(Get_Text_Struct(self)));
237
438
  }
238
439
 
440
+ /* call-seq:
441
+ * origin=(value) -> Vector2
442
+ *
443
+ * Sets the object's origin.
444
+ *
445
+ * @return [Vector2] +value+
446
+ */
239
447
  static VALUE Text_set_origin(VALUE self, VALUE rb_origin) {
240
448
  sfText_setOrigin(Get_Text_Struct(self), vec2f_from_rb(rb_origin));
241
449
  return rb_origin;
242
450
  }
243
451
 
452
+ /* call-seq:
453
+ * move(offset) -> self
454
+ *
455
+ * Moves the object by +offset+.
456
+ *
457
+ * @return [self]
458
+ */
244
459
  static VALUE Text_move(VALUE self, VALUE rb_offset) {
245
460
  sfText_move(Get_Text_Struct(self), vec2f_from_rb(rb_offset));
246
461
  return self;
247
462
  }
248
463
 
464
+ /* call-seq:
465
+ * rotate(angle) -> self
466
+ *
467
+ * Rotates the object by +angle+ degrees.
468
+ *
469
+ * @return [self]
470
+ */
249
471
  static VALUE Text_rotate(VALUE self, VALUE rb_angle) {
250
472
  sfText_rotate(Get_Text_Struct(self), NUM2DBL(rb_angle));
251
473
  return self;
252
474
  }
253
475
 
476
+ /* call-seq:
477
+ * scale!(factors) -> self
478
+ *
479
+ * Scales the object by +factors+ relative to its current scale.
480
+ *
481
+ * @return [self]
482
+ */
254
483
  static VALUE Text_scale(VALUE self, VALUE rb_factors) {
255
484
  sfText_scale(Get_Text_Struct(self), vec2f_from_rb(rb_factors));
256
485
  return self;
257
486
  }
258
487
 
488
+ /* call-seq: transform -> Array<Float>
489
+ *
490
+ * Returns the object's 3x3 row-major transform matrix.
491
+ *
492
+ * @return [Array<Float>] the 9-element matrix (also available as #matrix)
493
+ */
259
494
  static VALUE Text_get_transform(VALUE self) {
260
495
  return Transform_MatrixToArray(sfText_getTransform(Get_Text_Struct(self)).matrix);
261
496
  }
262
497
 
498
+ /* call-seq: inverse_transform -> Array<Float>
499
+ *
500
+ * Returns the 3x3 row-major inverse of the object's transform matrix.
501
+ *
502
+ * @return [Array<Float>] the inverse of #transform
503
+ */
263
504
  static VALUE Text_get_inverse_transform(VALUE self) {
264
505
  return Transform_MatrixToArray(sfText_getInverseTransform(Get_Text_Struct(self)).matrix);
265
506
  }
266
507
 
508
+ /* call-seq:
509
+ * find_character_pos(index) -> Vector2
510
+ *
511
+ * Returns the index of the character at the given position.
512
+ *
513
+ * @return [Vector2] the position of the +index+-th character, in global
514
+ * (parent) coordinates
515
+ */
267
516
  static VALUE Text_find_character_pos(VALUE self, VALUE rb_index) {
268
517
  return vec2f_to_rb(sfText_findCharacterPos(Get_Text_Struct(self), (size_t)NUM2SIZET(rb_index)));
269
518
  }
270
519
 
520
+ /* call-seq: local_bounds -> Rect
521
+ *
522
+ * Returns the bounding box in local (untransformed) coordinates.
523
+ *
524
+ * @return [Rect] the bounding box in local coordinates, before any
525
+ * transform is applied
526
+ */
271
527
  static VALUE Text_get_local_bounds(VALUE self) {
272
528
  return rect_to_rb(sfText_getLocalBounds(Get_Text_Struct(self)));
273
529
  }
274
530
 
531
+ /* call-seq: global_bounds -> Rect
532
+ *
533
+ * Returns the bounding box after the transform is applied.
534
+ *
535
+ * @return [Rect] the bounding box in the parent's coordinate system, after
536
+ * the current transform is applied
537
+ */
275
538
  static VALUE Text_get_global_bounds(VALUE self) {
276
539
  return rect_to_rb(sfText_getGlobalBounds(Get_Text_Struct(self)));
277
540
  }
278
541
 
542
+ /* call-seq:
543
+ * draw(target, state) -> nil
544
+ *
545
+ * Part of the Drawable interface; call Target#draw instead of this
546
+ * directly.
547
+ *
548
+ * @return [nil]
549
+ * @raise [TypeError] if +target+ is not a Target or +state+ is not a
550
+ * RenderState
551
+ */
279
552
  static VALUE Text_draw(VALUE self, VALUE rb_target, VALUE rb_state) {
280
- if (!rb_obj_is_kind_of(rb_target, Get_Klass_Target())) {
281
- raise_invalid_argument_class(Get_Klass_Target());
282
- }
553
+ TargetView view = Get_RenderTarget_View(rb_target);
283
554
 
284
555
  if (!rb_obj_is_kind_of(rb_state, Get_Klass_RenderState())) {
285
556
  raise_invalid_argument_class(Get_Klass_RenderState());
286
557
  }
287
558
 
288
- TARGET_DRAW(Get_Target_Struct(rb_target), sfRenderWindow_drawText, sfRenderTexture_drawText,
289
- Get_Text_Struct(self), Get_RenderState_Struct(rb_state));
559
+ TARGET_DRAW(view, sfRenderWindow_drawText, sfRenderTexture_drawText, Get_Text_Struct(self),
560
+ Get_RenderState_Struct(rb_state));
290
561
 
291
562
  return Qnil;
292
563
  }
293
564
 
294
- void Init_Text(VALUE rb_module) {
295
- rb_cText = rb_define_class_under(rb_module, "Text", rb_cObject);
565
+ /* Document-class: SFML::Text
566
+ * A drawable string of characters, rendered using a Font, positioned,
567
+ * rotated, scaled and tinted like any other Transformable object.
568
+ *
569
+ * Includes +Drawable+.
570
+ *
571
+ * @!attribute font
572
+ * The text's font.
573
+ * @return [Font, nil]
574
+ * @!attribute string
575
+ * The displayed string.
576
+ * @return [String]
577
+ * @!attribute character_size
578
+ * The character size in pixels.
579
+ * @return [Integer] in pixels
580
+ * @!attribute style
581
+ * The text style flags.
582
+ * @return [Integer] a bitmask of style flags
583
+ * @!attribute fill_color
584
+ * The object's fill color.
585
+ * @return [Color]
586
+ * @!attribute outline_color
587
+ * The object's outline color.
588
+ * @return [Color]
589
+ * @!attribute outline_thickness
590
+ * The object's outline thickness.
591
+ * @return [Float]
592
+ * @!attribute letter_spacing
593
+ * The spacing between letters.
594
+ * @return [Float]
595
+ * @!attribute line_spacing
596
+ * The spacing between lines.
597
+ * @return [Float]
598
+ * @!attribute position
599
+ * The object's position.
600
+ * @return [Vector2]
601
+ * @!attribute rotation
602
+ * The object's rotation, in degrees.
603
+ * @return [Float] degrees
604
+ * @!attribute scale
605
+ * The object's scale factors.
606
+ * @return [Vector2]
607
+ * @!attribute origin
608
+ * The object's origin.
609
+ * @return [Vector2]
610
+ */
611
+ void Init_Text(VALUE rb_mSFML) {
612
+ rb_cText = rb_define_class_under(rb_mSFML, "Text", rb_cObject);
613
+
614
+ rb_define_alloc_func(rb_cText, Text_alloc);
296
615
 
297
616
  rb_include_module(rb_cText, Get_Module_Drawable());
298
617
 
299
- rb_define_singleton_method(rb_cText, "new", Text_new, -1);
618
+ rb_define_method(rb_cText, "initialize", Text_initialize, -1);
619
+ rb_define_private_method(rb_cText, "initialize_copy", Text_initialize_copy, 1);
300
620
 
301
621
  rb_define_method(rb_cText, "copy", Text_copy, 0);
302
622
  rb_define_method(rb_cText, "font", Text_get_font, 0);