sfml3-rb 0.0.1 → 0.2.2
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/CHANGELOG.md +342 -0
- data/README.md +51 -14
- data/TODO.md +199 -0
- data/ext/audio/audio_enums.c +131 -0
- data/ext/audio/audio_enums.h +18 -0
- data/ext/audio/effect_processor.c +233 -0
- data/ext/audio/effect_processor.h +25 -0
- data/ext/audio/listener.c +83 -0
- data/ext/audio/listener.h +8 -0
- data/ext/audio/music.c +174 -0
- data/ext/audio/music.h +14 -0
- data/ext/audio/sound.c +139 -0
- data/ext/audio/sound.h +14 -0
- data/ext/audio/sound_buffer.c +274 -0
- data/ext/audio/sound_buffer.h +18 -0
- data/ext/audio/sound_buffer_recorder.c +109 -0
- data/ext/audio/sound_buffer_recorder.h +14 -0
- data/ext/audio/sound_recorder.c +268 -0
- data/ext/audio/sound_recorder.h +14 -0
- data/ext/audio/sound_source.h +13 -0
- data/ext/audio/sound_source.inc +271 -0
- data/ext/audio/sound_source_cone.c +138 -0
- data/ext/audio/sound_source_cone.h +20 -0
- data/ext/audio/sound_stream.c +294 -0
- data/ext/audio/sound_stream.h +14 -0
- data/ext/{exceptions.c → core/exceptions.c} +10 -8
- data/ext/{ext → core}/exceptions.h +3 -3
- data/ext/core/foreign_thread.c +149 -0
- data/ext/core/foreign_thread.h +31 -0
- data/ext/core/macros.h +8 -0
- data/ext/{ext → core}/sfml.h +5 -3
- data/ext/core/unicode.c +46 -0
- data/ext/core/unicode.h +25 -0
- data/ext/ext.c +125 -14
- data/ext/extconf.rb +51 -6
- data/ext/graphics/blend_mode.c +261 -0
- data/ext/graphics/blend_mode.h +18 -0
- data/ext/graphics/circle.c +319 -0
- data/ext/{ext/klass/drawable → graphics}/circle.h +3 -3
- data/ext/graphics/color.c +318 -0
- data/ext/graphics/color.h +37 -0
- data/ext/{drawable.c → graphics/drawable.c} +11 -11
- data/ext/graphics/drawable.h +10 -0
- data/ext/graphics/enums.c +123 -0
- data/ext/graphics/enums.h +20 -0
- data/ext/graphics/font.c +148 -0
- data/ext/graphics/font.h +14 -0
- data/ext/graphics/glyph.c +60 -0
- data/ext/graphics/glyph.h +14 -0
- data/ext/graphics/image.c +205 -0
- data/ext/graphics/image.h +16 -0
- data/ext/graphics/polygon.c +300 -0
- data/ext/graphics/polygon.h +10 -0
- data/ext/graphics/rect.c +287 -0
- data/ext/graphics/rect.h +30 -0
- data/ext/graphics/rectangle.c +302 -0
- data/ext/graphics/rectangle.h +10 -0
- data/ext/graphics/render_state.c +204 -0
- data/ext/graphics/render_state.h +18 -0
- data/ext/graphics/render_target.inc +181 -0
- data/ext/graphics/render_texture.c +182 -0
- data/ext/graphics/render_texture.h +14 -0
- data/ext/graphics/shader.c +540 -0
- data/ext/graphics/shader.h +14 -0
- data/ext/graphics/shape.c +311 -0
- data/ext/graphics/shape.h +10 -0
- data/ext/graphics/sprite.c +249 -0
- data/ext/graphics/sprite.h +10 -0
- data/ext/graphics/stencil_mode.c +211 -0
- data/ext/graphics/stencil_mode.h +18 -0
- data/ext/graphics/target.c +133 -0
- data/ext/graphics/target.h +40 -0
- data/ext/graphics/text.c +344 -0
- data/ext/graphics/text.h +10 -0
- data/ext/graphics/texture.c +379 -0
- data/ext/graphics/texture.h +16 -0
- data/ext/graphics/transform.c +372 -0
- data/ext/graphics/transform.h +35 -0
- data/ext/{transformable.c → graphics/transformable.c} +168 -144
- data/ext/{ext/klass → graphics}/transformable.h +3 -3
- data/ext/graphics/vertex.c +179 -0
- data/ext/graphics/vertex.h +23 -0
- data/ext/graphics/vertex_array.c +127 -0
- data/ext/graphics/vertex_array.h +10 -0
- data/ext/graphics/vertex_buffer.c +211 -0
- data/ext/graphics/vertex_buffer.h +14 -0
- data/ext/{view.c → graphics/view.c} +168 -169
- data/ext/{ext/klass → graphics}/view.h +3 -3
- data/ext/network/ftp.c +405 -0
- data/ext/network/ftp.h +20 -0
- data/ext/network/http.c +243 -0
- data/ext/network/http.h +18 -0
- data/ext/network/ip_address.c +164 -0
- data/ext/network/ip_address.h +20 -0
- data/ext/network/network_enums.c +298 -0
- data/ext/network/network_enums.h +26 -0
- data/ext/network/packet.c +189 -0
- data/ext/network/packet.h +14 -0
- data/ext/network/socket_selector.c +142 -0
- data/ext/network/socket_selector.h +14 -0
- data/ext/network/tcp_listener.c +115 -0
- data/ext/network/tcp_listener.h +14 -0
- data/ext/network/tcp_socket.c +199 -0
- data/ext/network/tcp_socket.h +17 -0
- data/ext/network/udp_socket.c +190 -0
- data/ext/network/udp_socket.h +14 -0
- data/ext/ports.rb +97 -21
- data/ext/system/buffer.c +77 -0
- data/ext/system/buffer.h +14 -0
- data/ext/system/clock.c +100 -0
- data/ext/{ext/klass → system}/clock.h +3 -3
- data/ext/system/input_stream.c +229 -0
- data/ext/system/input_stream.h +23 -0
- data/ext/system/sleep.c +16 -0
- data/ext/system/sleep.h +8 -0
- data/ext/system/time.c +218 -0
- data/ext/system/time.h +18 -0
- data/ext/system/vec2.c +251 -0
- data/ext/system/vec2.h +55 -0
- data/ext/system/vec3.c +219 -0
- data/ext/system/vec3.h +18 -0
- data/ext/window/clipboard.c +89 -0
- data/ext/window/clipboard.h +8 -0
- data/ext/window/context.c +70 -0
- data/ext/window/context.h +8 -0
- data/ext/window/context_settings.c +220 -0
- data/ext/window/context_settings.h +18 -0
- data/ext/window/cursor.c +56 -0
- data/ext/window/cursor.h +14 -0
- data/ext/window/event.c +216 -0
- data/ext/window/event.h +14 -0
- data/ext/{event_name.c → window/event_name.c} +2 -2
- data/ext/window/event_name.h +8 -0
- data/ext/window/input_enums.c +261 -0
- data/ext/window/input_enums.h +36 -0
- data/ext/window/joystick.c +60 -0
- data/ext/window/joystick.h +8 -0
- data/ext/{keyboard.c → window/keyboard.c} +74 -2
- data/ext/window/keyboard.h +12 -0
- data/ext/window/mouse.c +70 -0
- data/ext/window/mouse.h +8 -0
- data/ext/window/sensor.c +30 -0
- data/ext/window/sensor.h +8 -0
- data/ext/window/touch.c +49 -0
- data/ext/window/touch.h +8 -0
- data/ext/window/video_mode.c +133 -0
- data/ext/window/video_mode.h +14 -0
- data/ext/window/vulkan.c +44 -0
- data/ext/window/vulkan.h +8 -0
- data/ext/window/window.c +414 -0
- data/ext/{ext/klass → window}/window.h +3 -3
- data/lib/sfml/version.rb +4 -2
- data/lib/sfml.rb +2 -0
- metadata +163 -56
- data/ext/circle.c +0 -198
- data/ext/clock.c +0 -65
- data/ext/color.c +0 -43
- data/ext/event.c +0 -148
- data/ext/ext/klass/color.h +0 -26
- data/ext/ext/klass/drawable/image.h +0 -4
- data/ext/ext/klass/drawable/polygon.h +0 -4
- data/ext/ext/klass/drawable/rectangle.h +0 -4
- data/ext/ext/klass/drawable/sprite.h +0 -4
- data/ext/ext/klass/drawable/texture.h +0 -4
- data/ext/ext/klass/event/event_name.h +0 -8
- data/ext/ext/klass/event.h +0 -12
- data/ext/ext/klass/keyboard.h +0 -8
- data/ext/ext/klass/render_state.h +0 -16
- data/ext/ext/klass/target.h +0 -18
- data/ext/ext/klass/transform.h +0 -17
- data/ext/ext/klass/video_mode.h +0 -12
- data/ext/ext/module/drawable/drawable.h +0 -10
- data/ext/ext/module/transform.h +0 -18
- data/ext/ext/module.h +0 -10
- data/ext/ext/rect.h +0 -16
- data/ext/ext/style_name.h +0 -11
- data/ext/ext/vec2.h +0 -38
- data/ext/image.c +0 -5
- data/ext/polygon.c +0 -5
- data/ext/rect.c +0 -26
- data/ext/rectangle.c +0 -5
- data/ext/render_state.c +0 -109
- data/ext/sprite.c +0 -5
- data/ext/style_name.c +0 -15
- data/ext/target.c +0 -106
- data/ext/texture.c +0 -5
- data/ext/transform.c +0 -107
- data/ext/vec2.c +0 -42
- data/ext/video_mode.c +0 -78
- data/ext/window.c +0 -274
data/ext/graphics/text.c
ADDED
|
@@ -0,0 +1,344 @@
|
|
|
1
|
+
#include "graphics/text.h"
|
|
2
|
+
|
|
3
|
+
#include <ruby.h>
|
|
4
|
+
#include <stdlib.h>
|
|
5
|
+
|
|
6
|
+
#include "graphics/drawable.h"
|
|
7
|
+
#include "graphics/target.h"
|
|
8
|
+
#include "graphics/render_state.h"
|
|
9
|
+
#include "graphics/transform.h"
|
|
10
|
+
#include "graphics/color.h"
|
|
11
|
+
#include "graphics/rect.h"
|
|
12
|
+
#include "graphics/font.h"
|
|
13
|
+
#include "graphics/enums.h"
|
|
14
|
+
#include "system/vec2.h"
|
|
15
|
+
#include "core/exceptions.h"
|
|
16
|
+
#include "core/macros.h"
|
|
17
|
+
#include "core/unicode.h"
|
|
18
|
+
|
|
19
|
+
typedef struct {
|
|
20
|
+
sfText* text;
|
|
21
|
+
VALUE rb_font;
|
|
22
|
+
} Text;
|
|
23
|
+
|
|
24
|
+
static VALUE rb_cText;
|
|
25
|
+
|
|
26
|
+
static void Text_mark(void* ptr) {
|
|
27
|
+
rb_gc_mark(((Text*)ptr)->rb_font);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
static void Text_free(void* ptr) {
|
|
31
|
+
sfText_destroy(((Text*)ptr)->text);
|
|
32
|
+
free(ptr);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
static const rb_data_type_t Text_data_type = {
|
|
36
|
+
.wrap_struct_name = "SFML::Text",
|
|
37
|
+
.function = {.dmark = Text_mark, .dfree = Text_free, .dsize = NULL},
|
|
38
|
+
.flags = RUBY_TYPED_FREE_IMMEDIATELY};
|
|
39
|
+
|
|
40
|
+
static Text* Get_Text(VALUE self) {
|
|
41
|
+
Text* ptr;
|
|
42
|
+
TypedData_Get_Struct(self, Text, &Text_data_type, ptr);
|
|
43
|
+
return ptr;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
static sfText* Get_Text_Struct(VALUE self) {
|
|
47
|
+
return Get_Text(self)->text;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
static VALUE Text_wrap(VALUE klass, sfText* text) {
|
|
51
|
+
Text* ptr;
|
|
52
|
+
|
|
53
|
+
if (text == NULL) {
|
|
54
|
+
rb_raise(rb_eRuntimeError, "failed to create text");
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
ptr = malloc(sizeof(Text));
|
|
58
|
+
ptr->text = text;
|
|
59
|
+
ptr->rb_font = Qnil;
|
|
60
|
+
|
|
61
|
+
return TypedData_Wrap_Struct(klass, &Text_data_type, ptr);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
static VALUE Text_new(int argc, VALUE* argv, VALUE klass) {
|
|
65
|
+
VALUE rb_font, rb_string, rb_size, self;
|
|
66
|
+
Text* ptr;
|
|
67
|
+
|
|
68
|
+
rb_scan_args(argc, argv, "03", &rb_font, &rb_string, &rb_size);
|
|
69
|
+
|
|
70
|
+
if (!NIL_P(rb_font) && !rb_obj_is_kind_of(rb_font, Get_Klass_Font())) {
|
|
71
|
+
raise_invalid_argument_class(Get_Klass_Font());
|
|
72
|
+
}
|
|
73
|
+
|
|
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;
|
|
77
|
+
|
|
78
|
+
if (ptr->text == NULL) {
|
|
79
|
+
free(ptr);
|
|
80
|
+
rb_raise(rb_eRuntimeError, "failed to create text");
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
self = TypedData_Wrap_Struct(klass, &Text_data_type, ptr);
|
|
84
|
+
|
|
85
|
+
if (!NIL_P(rb_string)) {
|
|
86
|
+
sfText_setString(ptr->text, StringValueCStr(rb_string));
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
if (!NIL_P(rb_size)) {
|
|
90
|
+
sfText_setCharacterSize(ptr->text, (unsigned int)NUM2UINT(rb_size));
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
return self;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
static VALUE Text_copy(VALUE self) {
|
|
97
|
+
Text* ptr = Get_Text(self);
|
|
98
|
+
VALUE copy = Text_wrap(Get_Klass_Text(), sfText_copy(ptr->text));
|
|
99
|
+
Text* copy_ptr = Get_Text(copy);
|
|
100
|
+
|
|
101
|
+
copy_ptr->rb_font = ptr->rb_font;
|
|
102
|
+
|
|
103
|
+
return copy;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
static VALUE Text_set_font(VALUE self, VALUE rb_font) {
|
|
107
|
+
Text* ptr = Get_Text(self);
|
|
108
|
+
|
|
109
|
+
if (NIL_P(rb_font)) {
|
|
110
|
+
ptr->rb_font = Qnil;
|
|
111
|
+
sfText_setFont(ptr->text, NULL);
|
|
112
|
+
return rb_font;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
if (!rb_obj_is_kind_of(rb_font, Get_Klass_Font())) {
|
|
116
|
+
raise_invalid_argument_class(Get_Klass_Font());
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
ptr->rb_font = rb_font;
|
|
120
|
+
sfText_setFont(ptr->text, Get_Font_Struct(rb_font));
|
|
121
|
+
|
|
122
|
+
return rb_font;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
static VALUE Text_get_font(VALUE self) {
|
|
126
|
+
return Get_Text(self)->rb_font;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/* Through the UTF-32 entry points, not sfText_setString: that one decodes the
|
|
130
|
+
bytes with the C locale and mangles anything outside ASCII. */
|
|
131
|
+
static VALUE Text_set_string(VALUE self, VALUE rb_string) {
|
|
132
|
+
VALUE buffer = utf32_from_rb(rb_string);
|
|
133
|
+
|
|
134
|
+
sfText_setUnicodeString(Get_Text_Struct(self), UTF32_PTR(buffer));
|
|
135
|
+
|
|
136
|
+
RB_GC_GUARD(buffer);
|
|
137
|
+
|
|
138
|
+
return rb_string;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
static VALUE Text_get_string(VALUE self) {
|
|
142
|
+
return utf32_to_rb(sfText_getUnicodeString(Get_Text_Struct(self)));
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
static VALUE Text_set_character_size(VALUE self, VALUE rb_size) {
|
|
146
|
+
sfText_setCharacterSize(Get_Text_Struct(self), (unsigned int)NUM2UINT(rb_size));
|
|
147
|
+
return rb_size;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
static VALUE Text_get_character_size(VALUE self) {
|
|
151
|
+
return UINT2NUM(sfText_getCharacterSize(Get_Text_Struct(self)));
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
static VALUE Text_set_style(VALUE self, VALUE rb_style) {
|
|
155
|
+
sfText_setStyle(Get_Text_Struct(self), text_style_from_rb(rb_style));
|
|
156
|
+
return rb_style;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
static VALUE Text_get_style(VALUE self) {
|
|
160
|
+
return text_style_to_rb(sfText_getStyle(Get_Text_Struct(self)));
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
static VALUE Text_get_fill_color(VALUE self) {
|
|
164
|
+
return color_to_rb(sfText_getFillColor(Get_Text_Struct(self)));
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
static VALUE Text_set_fill_color(VALUE self, VALUE rb_color) {
|
|
168
|
+
sfText_setFillColor(Get_Text_Struct(self), color_from_rb(rb_color));
|
|
169
|
+
return rb_color;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
static VALUE Text_get_outline_color(VALUE self) {
|
|
173
|
+
return color_to_rb(sfText_getOutlineColor(Get_Text_Struct(self)));
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
static VALUE Text_set_outline_color(VALUE self, VALUE rb_color) {
|
|
177
|
+
sfText_setOutlineColor(Get_Text_Struct(self), color_from_rb(rb_color));
|
|
178
|
+
return rb_color;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
static VALUE Text_get_outline_thickness(VALUE self) {
|
|
182
|
+
return DBL2NUM(sfText_getOutlineThickness(Get_Text_Struct(self)));
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
static VALUE Text_set_outline_thickness(VALUE self, VALUE rb_thickness) {
|
|
186
|
+
sfText_setOutlineThickness(Get_Text_Struct(self), NUM2DBL(rb_thickness));
|
|
187
|
+
return rb_thickness;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
static VALUE Text_get_letter_spacing(VALUE self) {
|
|
191
|
+
return DBL2NUM(sfText_getLetterSpacing(Get_Text_Struct(self)));
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
static VALUE Text_set_letter_spacing(VALUE self, VALUE rb_spacing) {
|
|
195
|
+
sfText_setLetterSpacing(Get_Text_Struct(self), NUM2DBL(rb_spacing));
|
|
196
|
+
return rb_spacing;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
static VALUE Text_get_line_spacing(VALUE self) {
|
|
200
|
+
return DBL2NUM(sfText_getLineSpacing(Get_Text_Struct(self)));
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
static VALUE Text_set_line_spacing(VALUE self, VALUE rb_spacing) {
|
|
204
|
+
sfText_setLineSpacing(Get_Text_Struct(self), NUM2DBL(rb_spacing));
|
|
205
|
+
return rb_spacing;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
static VALUE Text_get_position(VALUE self) {
|
|
209
|
+
return vec2f_to_rb(sfText_getPosition(Get_Text_Struct(self)));
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
static VALUE Text_set_position(VALUE self, VALUE rb_position) {
|
|
213
|
+
sfText_setPosition(Get_Text_Struct(self), vec2f_from_rb(rb_position));
|
|
214
|
+
return rb_position;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
static VALUE Text_get_rotation(VALUE self) {
|
|
218
|
+
return DBL2NUM(sfText_getRotation(Get_Text_Struct(self)));
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
static VALUE Text_set_rotation(VALUE self, VALUE rb_rotation) {
|
|
222
|
+
sfText_setRotation(Get_Text_Struct(self), NUM2DBL(rb_rotation));
|
|
223
|
+
return rb_rotation;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
static VALUE Text_get_scale(VALUE self) {
|
|
227
|
+
return vec2f_to_rb(sfText_getScale(Get_Text_Struct(self)));
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
static VALUE Text_set_scale(VALUE self, VALUE rb_scale) {
|
|
231
|
+
sfText_setScale(Get_Text_Struct(self), vec2f_from_rb(rb_scale));
|
|
232
|
+
return rb_scale;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
static VALUE Text_get_origin(VALUE self) {
|
|
236
|
+
return vec2f_to_rb(sfText_getOrigin(Get_Text_Struct(self)));
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
static VALUE Text_set_origin(VALUE self, VALUE rb_origin) {
|
|
240
|
+
sfText_setOrigin(Get_Text_Struct(self), vec2f_from_rb(rb_origin));
|
|
241
|
+
return rb_origin;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
static VALUE Text_move(VALUE self, VALUE rb_offset) {
|
|
245
|
+
sfText_move(Get_Text_Struct(self), vec2f_from_rb(rb_offset));
|
|
246
|
+
return self;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
static VALUE Text_rotate(VALUE self, VALUE rb_angle) {
|
|
250
|
+
sfText_rotate(Get_Text_Struct(self), NUM2DBL(rb_angle));
|
|
251
|
+
return self;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
static VALUE Text_scale(VALUE self, VALUE rb_factors) {
|
|
255
|
+
sfText_scale(Get_Text_Struct(self), vec2f_from_rb(rb_factors));
|
|
256
|
+
return self;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
static VALUE Text_get_transform(VALUE self) {
|
|
260
|
+
return Transform_MatrixToArray(sfText_getTransform(Get_Text_Struct(self)).matrix);
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
static VALUE Text_get_inverse_transform(VALUE self) {
|
|
264
|
+
return Transform_MatrixToArray(sfText_getInverseTransform(Get_Text_Struct(self)).matrix);
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
static VALUE Text_find_character_pos(VALUE self, VALUE rb_index) {
|
|
268
|
+
return vec2f_to_rb(sfText_findCharacterPos(Get_Text_Struct(self), (size_t)NUM2SIZET(rb_index)));
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
static VALUE Text_get_local_bounds(VALUE self) {
|
|
272
|
+
return rect_to_rb(sfText_getLocalBounds(Get_Text_Struct(self)));
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
static VALUE Text_get_global_bounds(VALUE self) {
|
|
276
|
+
return rect_to_rb(sfText_getGlobalBounds(Get_Text_Struct(self)));
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
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
|
+
}
|
|
283
|
+
|
|
284
|
+
if (!rb_obj_is_kind_of(rb_state, Get_Klass_RenderState())) {
|
|
285
|
+
raise_invalid_argument_class(Get_Klass_RenderState());
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
TARGET_DRAW(Get_Target_Struct(rb_target), sfRenderWindow_drawText, sfRenderTexture_drawText,
|
|
289
|
+
Get_Text_Struct(self), Get_RenderState_Struct(rb_state));
|
|
290
|
+
|
|
291
|
+
return Qnil;
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
void Init_Text(VALUE rb_module) {
|
|
295
|
+
rb_cText = rb_define_class_under(rb_module, "Text", rb_cObject);
|
|
296
|
+
|
|
297
|
+
rb_include_module(rb_cText, Get_Module_Drawable());
|
|
298
|
+
|
|
299
|
+
rb_define_singleton_method(rb_cText, "new", Text_new, -1);
|
|
300
|
+
|
|
301
|
+
rb_define_method(rb_cText, "copy", Text_copy, 0);
|
|
302
|
+
rb_define_method(rb_cText, "font", Text_get_font, 0);
|
|
303
|
+
rb_define_method(rb_cText, "string", Text_get_string, 0);
|
|
304
|
+
rb_define_method(rb_cText, "character_size", Text_get_character_size, 0);
|
|
305
|
+
rb_define_method(rb_cText, "style", Text_get_style, 0);
|
|
306
|
+
rb_define_method(rb_cText, "fill_color", Text_get_fill_color, 0);
|
|
307
|
+
rb_define_method(rb_cText, "outline_color", Text_get_outline_color, 0);
|
|
308
|
+
rb_define_method(rb_cText, "outline_thickness", Text_get_outline_thickness, 0);
|
|
309
|
+
rb_define_method(rb_cText, "letter_spacing", Text_get_letter_spacing, 0);
|
|
310
|
+
rb_define_method(rb_cText, "line_spacing", Text_get_line_spacing, 0);
|
|
311
|
+
rb_define_method(rb_cText, "position", Text_get_position, 0);
|
|
312
|
+
rb_define_method(rb_cText, "rotation", Text_get_rotation, 0);
|
|
313
|
+
rb_define_method(rb_cText, "scale", Text_get_scale, 0);
|
|
314
|
+
rb_define_method(rb_cText, "origin", Text_get_origin, 0);
|
|
315
|
+
rb_define_method(rb_cText, "transform", Text_get_transform, 0);
|
|
316
|
+
rb_define_method(rb_cText, "inverse_transform", Text_get_inverse_transform, 0);
|
|
317
|
+
rb_define_method(rb_cText, "matrix", Text_get_transform, 0);
|
|
318
|
+
rb_define_method(rb_cText, "find_character_pos", Text_find_character_pos, 1);
|
|
319
|
+
rb_define_method(rb_cText, "local_bounds", Text_get_local_bounds, 0);
|
|
320
|
+
rb_define_method(rb_cText, "global_bounds", Text_get_global_bounds, 0);
|
|
321
|
+
|
|
322
|
+
rb_define_method(rb_cText, "font=", Text_set_font, 1);
|
|
323
|
+
rb_define_method(rb_cText, "string=", Text_set_string, 1);
|
|
324
|
+
rb_define_method(rb_cText, "character_size=", Text_set_character_size, 1);
|
|
325
|
+
rb_define_method(rb_cText, "style=", Text_set_style, 1);
|
|
326
|
+
rb_define_method(rb_cText, "fill_color=", Text_set_fill_color, 1);
|
|
327
|
+
rb_define_method(rb_cText, "outline_color=", Text_set_outline_color, 1);
|
|
328
|
+
rb_define_method(rb_cText, "outline_thickness=", Text_set_outline_thickness, 1);
|
|
329
|
+
rb_define_method(rb_cText, "letter_spacing=", Text_set_letter_spacing, 1);
|
|
330
|
+
rb_define_method(rb_cText, "line_spacing=", Text_set_line_spacing, 1);
|
|
331
|
+
rb_define_method(rb_cText, "position=", Text_set_position, 1);
|
|
332
|
+
rb_define_method(rb_cText, "rotation=", Text_set_rotation, 1);
|
|
333
|
+
rb_define_method(rb_cText, "scale=", Text_set_scale, 1);
|
|
334
|
+
rb_define_method(rb_cText, "origin=", Text_set_origin, 1);
|
|
335
|
+
|
|
336
|
+
rb_define_method(rb_cText, "move", Text_move, 1);
|
|
337
|
+
rb_define_method(rb_cText, "rotate", Text_rotate, 1);
|
|
338
|
+
rb_define_method(rb_cText, "scale!", Text_scale, 1);
|
|
339
|
+
rb_define_method(rb_cText, "draw", Text_draw, 2);
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
VALUE Get_Klass_Text(void) {
|
|
343
|
+
return rb_cText;
|
|
344
|
+
}
|