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