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.
- checksums.yaml +4 -4
- data/.yardopts +9 -0
- data/CHANGELOG.md +67 -16
- data/README.md +123 -32
- data/TODO.md +18 -11
- data/ext/audio/audio_enums.c +58 -20
- data/ext/audio/listener.c +89 -6
- data/ext/audio/music.c +212 -5
- data/ext/audio/sound.c +218 -9
- data/ext/audio/sound_buffer.c +197 -47
- data/ext/audio/sound_buffer_recorder.c +90 -18
- data/ext/audio/sound_recorder.c +188 -58
- data/ext/audio/sound_source_cone.c +127 -33
- data/ext/audio/sound_stream.c +204 -21
- data/ext/core/exceptions.c +10 -8
- data/ext/core/unicode.c +12 -2
- data/ext/ext.c +8 -0
- data/ext/graphics/blend_mode.c +218 -60
- data/ext/graphics/circle.c +300 -16
- data/ext/graphics/color.c +253 -94
- data/ext/graphics/drawable.c +16 -4
- data/ext/graphics/font.c +144 -25
- data/ext/graphics/glyph.c +38 -8
- data/ext/graphics/image.c +205 -41
- data/ext/graphics/polygon.c +317 -30
- data/ext/graphics/rect.c +225 -60
- data/ext/graphics/rectangle.c +307 -35
- data/ext/graphics/render_state.c +124 -12
- data/ext/graphics/render_texture.c +191 -14
- data/ext/graphics/render_window.c +55 -0
- data/ext/graphics/render_window.h +10 -0
- data/ext/graphics/shader.c +289 -17
- data/ext/graphics/shape.c +265 -32
- data/ext/graphics/sprite.c +245 -30
- data/ext/graphics/stencil_mode.c +163 -46
- data/ext/graphics/target.c +121 -43
- data/ext/graphics/target.h +31 -17
- data/ext/graphics/text.c +339 -19
- data/ext/graphics/texture.c +291 -6
- data/ext/graphics/transform.c +178 -5
- data/ext/graphics/transformable.c +127 -12
- data/ext/graphics/vertex.c +98 -6
- data/ext/graphics/vertex_array.c +142 -21
- data/ext/graphics/vertex_buffer.c +154 -12
- data/ext/graphics/view.c +140 -6
- data/ext/network/ftp.c +278 -12
- data/ext/network/http.c +179 -44
- data/ext/network/ip_address.c +127 -35
- data/ext/network/network_enums.c +248 -141
- data/ext/network/packet.c +280 -41
- data/ext/network/socket_selector.c +98 -21
- data/ext/network/tcp_listener.c +82 -18
- data/ext/network/tcp_socket.c +135 -27
- data/ext/network/udp_socket.c +129 -28
- data/ext/ports.rb +7 -0
- data/ext/system/buffer.c +47 -16
- data/ext/system/clock.c +77 -12
- data/ext/system/input_stream.c +113 -51
- data/ext/system/sleep.c +10 -2
- data/ext/system/time.c +182 -40
- data/ext/system/vec2.c +166 -39
- data/ext/system/vec3.c +177 -39
- data/ext/window/clipboard.c +47 -17
- data/ext/window/context.c +66 -13
- data/ext/window/context_settings.c +132 -42
- data/ext/window/cursor.c +45 -9
- data/ext/window/event.c +164 -53
- data/ext/window/joystick.c +69 -3
- data/ext/window/keyboard.c +168 -116
- data/ext/window/mouse.c +64 -13
- data/ext/window/sensor.c +28 -2
- data/ext/window/touch.c +32 -12
- data/ext/window/video_mode.c +93 -31
- data/ext/window/vulkan.c +34 -6
- data/ext/window/window.c +228 -229
- data/ext/window/window.h +4 -4
- data/ext/window/window_base.c +251 -0
- data/ext/window/window_base.h +43 -0
- data/ext/window/window_base.inc +236 -0
- 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_target.rbs +18 -0
- data/sig/graphics/render_texture.rbs +39 -0
- data/sig/graphics/render_window.rbs +7 -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 +8 -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 +23 -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/sfml/version.rbs +3 -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 +34 -0
- data/sig/window/window_base.rbs +33 -0
- metadata +76 -3
data/ext/graphics/rectangle.c
CHANGED
|
@@ -16,39 +16,38 @@
|
|
|
16
16
|
#include "core/macros.h"
|
|
17
17
|
|
|
18
18
|
typedef struct {
|
|
19
|
-
sfRectangleShape
|
|
19
|
+
sfRectangleShape* shape;
|
|
20
20
|
VALUE rb_texture;
|
|
21
21
|
} RectangleShape;
|
|
22
22
|
|
|
23
23
|
static VALUE rb_cRectangleShape;
|
|
24
24
|
|
|
25
|
-
static void RectangleShape_mark(void
|
|
26
|
-
rb_gc_mark(((RectangleShape
|
|
25
|
+
static void RectangleShape_mark(void* ptr) {
|
|
26
|
+
rb_gc_mark(((RectangleShape*)ptr)->rb_texture);
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
static void RectangleShape_free(void
|
|
30
|
-
sfRectangleShape_destroy(((RectangleShape
|
|
29
|
+
static void RectangleShape_free(void* ptr) {
|
|
30
|
+
sfRectangleShape_destroy(((RectangleShape*)ptr)->shape);
|
|
31
31
|
free(ptr);
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
static const rb_data_type_t RectangleShape_data_type = {
|
|
35
35
|
.wrap_struct_name = "SFML::RectangleShape",
|
|
36
36
|
.function = {.dmark = RectangleShape_mark, .dfree = RectangleShape_free, .dsize = NULL},
|
|
37
|
-
.flags = RUBY_TYPED_FREE_IMMEDIATELY
|
|
38
|
-
};
|
|
37
|
+
.flags = RUBY_TYPED_FREE_IMMEDIATELY};
|
|
39
38
|
|
|
40
|
-
static RectangleShape
|
|
41
|
-
RectangleShape
|
|
39
|
+
static RectangleShape* Get_RectangleShape(VALUE self) {
|
|
40
|
+
RectangleShape* ptr;
|
|
42
41
|
TypedData_Get_Struct(self, RectangleShape, &RectangleShape_data_type, ptr);
|
|
43
42
|
return ptr;
|
|
44
43
|
}
|
|
45
44
|
|
|
46
|
-
static sfRectangleShape
|
|
45
|
+
static sfRectangleShape* Get_RectangleShape_Struct(VALUE self) {
|
|
47
46
|
return Get_RectangleShape(self)->shape;
|
|
48
47
|
}
|
|
49
48
|
|
|
50
|
-
static VALUE RectangleShape_wrap(VALUE klass, sfRectangleShape
|
|
51
|
-
RectangleShape
|
|
49
|
+
static VALUE RectangleShape_wrap(VALUE klass, sfRectangleShape* shape) {
|
|
50
|
+
RectangleShape* ptr;
|
|
52
51
|
|
|
53
52
|
if (shape == NULL) {
|
|
54
53
|
rb_raise(rb_eRuntimeError, "failed to create rectangle shape");
|
|
@@ -61,25 +60,59 @@ static VALUE RectangleShape_wrap(VALUE klass, sfRectangleShape *shape) {
|
|
|
61
60
|
return TypedData_Wrap_Struct(klass, &RectangleShape_data_type, ptr);
|
|
62
61
|
}
|
|
63
62
|
|
|
64
|
-
static VALUE
|
|
65
|
-
|
|
63
|
+
static VALUE RectangleShape_alloc(VALUE klass) {
|
|
64
|
+
RectangleShape* ptr = malloc(sizeof(RectangleShape));
|
|
65
|
+
sfRectangleShape* shape;
|
|
66
|
+
|
|
67
|
+
if (ptr == NULL) {
|
|
68
|
+
rb_raise(rb_eNoMemError, "failed to allocate rectangle shape");
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
shape = sfRectangleShape_create();
|
|
72
|
+
|
|
73
|
+
if (shape == NULL) {
|
|
74
|
+
free(ptr);
|
|
75
|
+
rb_raise(rb_eRuntimeError, "failed to create rectangle shape");
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
ptr->shape = shape;
|
|
79
|
+
ptr->rb_texture = Qnil;
|
|
80
|
+
|
|
81
|
+
return TypedData_Wrap_Struct(klass, &RectangleShape_data_type, ptr);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/* call-seq:
|
|
85
|
+
* RectangleShape.new(size = Vector2.new(0, 0)) -> RectangleShape
|
|
86
|
+
*
|
|
87
|
+
* Creates a rectangle shape with the given +size+.
|
|
88
|
+
*
|
|
89
|
+
* @return [RectangleShape]
|
|
90
|
+
*/
|
|
91
|
+
static VALUE RectangleShape_initialize(int argc, VALUE* argv, VALUE self) {
|
|
66
92
|
VALUE rb_size;
|
|
67
93
|
|
|
68
94
|
rb_scan_args(argc, argv, "01", &rb_size);
|
|
69
95
|
|
|
70
96
|
if (!NIL_P(rb_size)) {
|
|
71
|
-
sfRectangleShape_setSize(
|
|
97
|
+
sfRectangleShape_setSize(Get_RectangleShape_Struct(self), vec2f_from_rb(rb_size));
|
|
72
98
|
}
|
|
73
99
|
|
|
74
|
-
return
|
|
100
|
+
return self;
|
|
75
101
|
}
|
|
76
102
|
|
|
103
|
+
/* call-seq: copy -> RectangleShape
|
|
104
|
+
*
|
|
105
|
+
* Returns a deep copy of the object.
|
|
106
|
+
*
|
|
107
|
+
* @return [RectangleShape] an independent copy, including its texture
|
|
108
|
+
* reference
|
|
109
|
+
*/
|
|
77
110
|
static VALUE RectangleShape_copy(VALUE self) {
|
|
78
|
-
RectangleShape
|
|
111
|
+
RectangleShape* ptr = Get_RectangleShape(self);
|
|
79
112
|
VALUE copy = RectangleShape_wrap(Get_Klass_RectangleShape(), sfRectangleShape_copy(ptr->shape));
|
|
80
113
|
|
|
81
114
|
if (!NIL_P(ptr->rb_texture)) {
|
|
82
|
-
RectangleShape
|
|
115
|
+
RectangleShape* copy_ptr = Get_RectangleShape(copy);
|
|
83
116
|
|
|
84
117
|
copy_ptr->rb_texture = ptr->rb_texture;
|
|
85
118
|
sfRectangleShape_setTexture(copy_ptr->shape, Get_Texture_Struct(ptr->rb_texture), false);
|
|
@@ -88,103 +121,247 @@ static VALUE RectangleShape_copy(VALUE self) {
|
|
|
88
121
|
return copy;
|
|
89
122
|
}
|
|
90
123
|
|
|
124
|
+
/* call-seq: size -> Vector2
|
|
125
|
+
*
|
|
126
|
+
* Returns the object's size.
|
|
127
|
+
*
|
|
128
|
+
* @return [Vector2]
|
|
129
|
+
*/
|
|
91
130
|
static VALUE RectangleShape_get_size(VALUE self) {
|
|
92
131
|
return vec2f_to_rb(sfRectangleShape_getSize(Get_RectangleShape_Struct(self)));
|
|
93
132
|
}
|
|
94
133
|
|
|
134
|
+
/* call-seq:
|
|
135
|
+
* size=(value) -> Vector2
|
|
136
|
+
*
|
|
137
|
+
* Sets the object's size.
|
|
138
|
+
*
|
|
139
|
+
* @return [Vector2] +value+
|
|
140
|
+
*/
|
|
95
141
|
static VALUE RectangleShape_set_size(VALUE self, VALUE rb_size) {
|
|
96
142
|
sfRectangleShape_setSize(Get_RectangleShape_Struct(self), vec2f_from_rb(rb_size));
|
|
97
143
|
return rb_size;
|
|
98
144
|
}
|
|
99
145
|
|
|
146
|
+
/* call-seq: position -> Vector2
|
|
147
|
+
*
|
|
148
|
+
* Returns the object's position.
|
|
149
|
+
*
|
|
150
|
+
* @return [Vector2]
|
|
151
|
+
*/
|
|
100
152
|
static VALUE RectangleShape_get_position(VALUE self) {
|
|
101
153
|
return vec2f_to_rb(sfRectangleShape_getPosition(Get_RectangleShape_Struct(self)));
|
|
102
154
|
}
|
|
103
155
|
|
|
156
|
+
/* call-seq:
|
|
157
|
+
* position=(value) -> Vector2
|
|
158
|
+
*
|
|
159
|
+
* Sets the object's position.
|
|
160
|
+
*
|
|
161
|
+
* @return [Vector2] +value+
|
|
162
|
+
*/
|
|
104
163
|
static VALUE RectangleShape_set_position(VALUE self, VALUE rb_position) {
|
|
105
164
|
sfRectangleShape_setPosition(Get_RectangleShape_Struct(self), vec2f_from_rb(rb_position));
|
|
106
165
|
return rb_position;
|
|
107
166
|
}
|
|
108
167
|
|
|
168
|
+
/* call-seq: rotation -> Float
|
|
169
|
+
*
|
|
170
|
+
* Returns the object's rotation, in degrees.
|
|
171
|
+
*
|
|
172
|
+
* @return [Float]
|
|
173
|
+
*/
|
|
109
174
|
static VALUE RectangleShape_get_rotation(VALUE self) {
|
|
110
175
|
return DBL2NUM(sfRectangleShape_getRotation(Get_RectangleShape_Struct(self)));
|
|
111
176
|
}
|
|
112
177
|
|
|
178
|
+
/* call-seq:
|
|
179
|
+
* rotation=(value) -> Float
|
|
180
|
+
*
|
|
181
|
+
* Sets the object's rotation, in degrees.
|
|
182
|
+
*
|
|
183
|
+
* @return [Float] +value+
|
|
184
|
+
*/
|
|
113
185
|
static VALUE RectangleShape_set_rotation(VALUE self, VALUE rb_rotation) {
|
|
114
186
|
sfRectangleShape_setRotation(Get_RectangleShape_Struct(self), NUM2DBL(rb_rotation));
|
|
115
187
|
return rb_rotation;
|
|
116
188
|
}
|
|
117
189
|
|
|
190
|
+
/* call-seq: scale -> Vector2
|
|
191
|
+
*
|
|
192
|
+
* Returns the object's scale factors.
|
|
193
|
+
*
|
|
194
|
+
* @return [Vector2]
|
|
195
|
+
*/
|
|
118
196
|
static VALUE RectangleShape_get_scale(VALUE self) {
|
|
119
197
|
return vec2f_to_rb(sfRectangleShape_getScale(Get_RectangleShape_Struct(self)));
|
|
120
198
|
}
|
|
121
199
|
|
|
200
|
+
/* call-seq:
|
|
201
|
+
* scale=(value) -> Vector2
|
|
202
|
+
*
|
|
203
|
+
* Sets the object's scale factors.
|
|
204
|
+
*
|
|
205
|
+
* @return [Vector2] +value+
|
|
206
|
+
*/
|
|
122
207
|
static VALUE RectangleShape_set_scale(VALUE self, VALUE rb_scale) {
|
|
123
208
|
sfRectangleShape_setScale(Get_RectangleShape_Struct(self), vec2f_from_rb(rb_scale));
|
|
124
209
|
return rb_scale;
|
|
125
210
|
}
|
|
126
211
|
|
|
212
|
+
/* call-seq: origin -> Vector2
|
|
213
|
+
*
|
|
214
|
+
* Returns the object's origin.
|
|
215
|
+
*
|
|
216
|
+
* @return [Vector2]
|
|
217
|
+
*/
|
|
127
218
|
static VALUE RectangleShape_get_origin(VALUE self) {
|
|
128
219
|
return vec2f_to_rb(sfRectangleShape_getOrigin(Get_RectangleShape_Struct(self)));
|
|
129
220
|
}
|
|
130
221
|
|
|
222
|
+
/* call-seq:
|
|
223
|
+
* origin=(value) -> Vector2
|
|
224
|
+
*
|
|
225
|
+
* Sets the object's origin.
|
|
226
|
+
*
|
|
227
|
+
* @return [Vector2] +value+
|
|
228
|
+
*/
|
|
131
229
|
static VALUE RectangleShape_set_origin(VALUE self, VALUE rb_origin) {
|
|
132
230
|
sfRectangleShape_setOrigin(Get_RectangleShape_Struct(self), vec2f_from_rb(rb_origin));
|
|
133
231
|
return rb_origin;
|
|
134
232
|
}
|
|
135
233
|
|
|
234
|
+
/* call-seq: move(offset) -> self
|
|
235
|
+
*
|
|
236
|
+
* Moves the object by +offset+.
|
|
237
|
+
*
|
|
238
|
+
* @return [self]
|
|
239
|
+
*/
|
|
136
240
|
static VALUE RectangleShape_move(VALUE self, VALUE rb_offset) {
|
|
137
241
|
sfRectangleShape_move(Get_RectangleShape_Struct(self), vec2f_from_rb(rb_offset));
|
|
138
242
|
return self;
|
|
139
243
|
}
|
|
140
244
|
|
|
245
|
+
/* call-seq: rotate(angle) -> self
|
|
246
|
+
*
|
|
247
|
+
* Rotates the object by +angle+ degrees.
|
|
248
|
+
*
|
|
249
|
+
* @return [self]
|
|
250
|
+
*/
|
|
141
251
|
static VALUE RectangleShape_rotate(VALUE self, VALUE rb_angle) {
|
|
142
252
|
sfRectangleShape_rotate(Get_RectangleShape_Struct(self), NUM2DBL(rb_angle));
|
|
143
253
|
return self;
|
|
144
254
|
}
|
|
145
255
|
|
|
256
|
+
/* call-seq:
|
|
257
|
+
* scale!(factors) -> self
|
|
258
|
+
*
|
|
259
|
+
* Scales the object by +factors+ relative to its current scale.
|
|
260
|
+
*
|
|
261
|
+
* @return [self]
|
|
262
|
+
*/
|
|
146
263
|
static VALUE RectangleShape_scale(VALUE self, VALUE rb_factors) {
|
|
147
264
|
sfRectangleShape_scale(Get_RectangleShape_Struct(self), vec2f_from_rb(rb_factors));
|
|
148
265
|
return self;
|
|
149
266
|
}
|
|
150
267
|
|
|
268
|
+
/* call-seq: transform -> Array
|
|
269
|
+
*
|
|
270
|
+
* Also available as #matrix.
|
|
271
|
+
*
|
|
272
|
+
* @return [Array] the 3x3 row-major transform matrix
|
|
273
|
+
*/
|
|
151
274
|
static VALUE RectangleShape_get_transform(VALUE self) {
|
|
152
|
-
return Transform_MatrixToArray(
|
|
275
|
+
return Transform_MatrixToArray(
|
|
276
|
+
sfRectangleShape_getTransform(Get_RectangleShape_Struct(self)).matrix);
|
|
153
277
|
}
|
|
154
278
|
|
|
279
|
+
/* call-seq: inverse_transform -> Array
|
|
280
|
+
*
|
|
281
|
+
* Returns the 3x3 row-major inverse of the object's transform matrix.
|
|
282
|
+
*
|
|
283
|
+
* @return [Array] the 3x3 row-major inverse transform matrix
|
|
284
|
+
*/
|
|
155
285
|
static VALUE RectangleShape_get_inverse_transform(VALUE self) {
|
|
156
|
-
return Transform_MatrixToArray(
|
|
286
|
+
return Transform_MatrixToArray(
|
|
287
|
+
sfRectangleShape_getInverseTransform(Get_RectangleShape_Struct(self)).matrix);
|
|
157
288
|
}
|
|
158
289
|
|
|
290
|
+
/* call-seq: fill_color -> Color
|
|
291
|
+
*
|
|
292
|
+
* Returns the shape's fill color.
|
|
293
|
+
*
|
|
294
|
+
* @return [Color]
|
|
295
|
+
*/
|
|
159
296
|
static VALUE RectangleShape_get_fill_color(VALUE self) {
|
|
160
297
|
return color_to_rb(sfRectangleShape_getFillColor(Get_RectangleShape_Struct(self)));
|
|
161
298
|
}
|
|
162
299
|
|
|
300
|
+
/* call-seq:
|
|
301
|
+
* fill_color=(value) -> Color
|
|
302
|
+
*
|
|
303
|
+
* Sets the shape's fill color.
|
|
304
|
+
*
|
|
305
|
+
* @return [Color] +value+
|
|
306
|
+
*/
|
|
163
307
|
static VALUE RectangleShape_set_fill_color(VALUE self, VALUE rb_color) {
|
|
164
308
|
sfRectangleShape_setFillColor(Get_RectangleShape_Struct(self), color_from_rb(rb_color));
|
|
165
309
|
return rb_color;
|
|
166
310
|
}
|
|
167
311
|
|
|
312
|
+
/* call-seq: outline_color -> Color
|
|
313
|
+
*
|
|
314
|
+
* Returns the shape's outline color.
|
|
315
|
+
*
|
|
316
|
+
* @return [Color]
|
|
317
|
+
*/
|
|
168
318
|
static VALUE RectangleShape_get_outline_color(VALUE self) {
|
|
169
319
|
return color_to_rb(sfRectangleShape_getOutlineColor(Get_RectangleShape_Struct(self)));
|
|
170
320
|
}
|
|
171
321
|
|
|
322
|
+
/* call-seq:
|
|
323
|
+
* outline_color=(value) -> Color
|
|
324
|
+
*
|
|
325
|
+
* Sets the shape's outline color.
|
|
326
|
+
*
|
|
327
|
+
* @return [Color] +value+
|
|
328
|
+
*/
|
|
172
329
|
static VALUE RectangleShape_set_outline_color(VALUE self, VALUE rb_color) {
|
|
173
330
|
sfRectangleShape_setOutlineColor(Get_RectangleShape_Struct(self), color_from_rb(rb_color));
|
|
174
331
|
return rb_color;
|
|
175
332
|
}
|
|
176
333
|
|
|
334
|
+
/* call-seq: outline_thickness -> Float
|
|
335
|
+
*
|
|
336
|
+
* Returns the shape's outline thickness.
|
|
337
|
+
*
|
|
338
|
+
* @return [Float]
|
|
339
|
+
*/
|
|
177
340
|
static VALUE RectangleShape_get_outline_thickness(VALUE self) {
|
|
178
341
|
return DBL2NUM(sfRectangleShape_getOutlineThickness(Get_RectangleShape_Struct(self)));
|
|
179
342
|
}
|
|
180
343
|
|
|
344
|
+
/* call-seq:
|
|
345
|
+
* outline_thickness=(value) -> Float
|
|
346
|
+
*
|
|
347
|
+
* Sets the shape's outline thickness.
|
|
348
|
+
*
|
|
349
|
+
* @return [Float] +value+
|
|
350
|
+
*/
|
|
181
351
|
static VALUE RectangleShape_set_outline_thickness(VALUE self, VALUE rb_thickness) {
|
|
182
352
|
sfRectangleShape_setOutlineThickness(Get_RectangleShape_Struct(self), NUM2DBL(rb_thickness));
|
|
183
353
|
return rb_thickness;
|
|
184
354
|
}
|
|
185
355
|
|
|
356
|
+
/* call-seq:
|
|
357
|
+
* texture=(value) -> Texture or nil
|
|
358
|
+
*
|
|
359
|
+
* Sets the object's texture.
|
|
360
|
+
*
|
|
361
|
+
* @return [Texture, nil] +value+
|
|
362
|
+
*/
|
|
186
363
|
static VALUE RectangleShape_set_texture(VALUE self, VALUE rb_texture) {
|
|
187
|
-
RectangleShape
|
|
364
|
+
RectangleShape* ptr = Get_RectangleShape(self);
|
|
188
365
|
bool reset_rect = false;
|
|
189
366
|
|
|
190
367
|
if (NIL_P(rb_texture)) {
|
|
@@ -203,61 +380,152 @@ static VALUE RectangleShape_set_texture(VALUE self, VALUE rb_texture) {
|
|
|
203
380
|
return rb_texture;
|
|
204
381
|
}
|
|
205
382
|
|
|
383
|
+
/* call-seq: texture -> Texture or nil
|
|
384
|
+
*
|
|
385
|
+
* Returns the object's texture, or +nil+ if it has none.
|
|
386
|
+
*
|
|
387
|
+
* @return [Texture, nil]
|
|
388
|
+
*/
|
|
206
389
|
static VALUE RectangleShape_get_texture(VALUE self) {
|
|
207
390
|
return Get_RectangleShape(self)->rb_texture;
|
|
208
391
|
}
|
|
209
392
|
|
|
393
|
+
/* call-seq: texture_rect -> Rect
|
|
394
|
+
*
|
|
395
|
+
* Returns the sub-rectangle of the texture displayed on the object.
|
|
396
|
+
*
|
|
397
|
+
* @return [Rect] the sub-rectangle of the texture displayed on the rectangle
|
|
398
|
+
*/
|
|
210
399
|
static VALUE RectangleShape_get_texture_rect(VALUE self) {
|
|
211
400
|
return int_rect_to_rb(sfRectangleShape_getTextureRect(Get_RectangleShape_Struct(self)));
|
|
212
401
|
}
|
|
213
402
|
|
|
403
|
+
/* call-seq:
|
|
404
|
+
* texture_rect=(value) -> Rect
|
|
405
|
+
*
|
|
406
|
+
* Sets the sub-rectangle of the texture displayed on the object.
|
|
407
|
+
*
|
|
408
|
+
* @return [Rect] +value+
|
|
409
|
+
*/
|
|
214
410
|
static VALUE RectangleShape_set_texture_rect(VALUE self, VALUE rb_rect) {
|
|
215
411
|
sfRectangleShape_setTextureRect(Get_RectangleShape_Struct(self), int_rect_from_rb(rb_rect));
|
|
216
412
|
return rb_rect;
|
|
217
413
|
}
|
|
218
414
|
|
|
415
|
+
/* call-seq: point_count -> Integer
|
|
416
|
+
*
|
|
417
|
+
* Returns the number of points composing the shape.
|
|
418
|
+
*
|
|
419
|
+
* @return [Integer] always 4
|
|
420
|
+
*/
|
|
219
421
|
static VALUE RectangleShape_get_point_count(VALUE self) {
|
|
220
422
|
return SIZET2NUM(sfRectangleShape_getPointCount(Get_RectangleShape_Struct(self)));
|
|
221
423
|
}
|
|
222
424
|
|
|
425
|
+
/* call-seq: point(index) -> Vector2
|
|
426
|
+
*
|
|
427
|
+
* Returns the local position of the point at +index+.
|
|
428
|
+
*
|
|
429
|
+
* @return [Vector2] the local position of the corner at +index+
|
|
430
|
+
*/
|
|
223
431
|
static VALUE RectangleShape_get_point(VALUE self, VALUE rb_index) {
|
|
224
|
-
return vec2f_to_rb(
|
|
432
|
+
return vec2f_to_rb(
|
|
433
|
+
sfRectangleShape_getPoint(Get_RectangleShape_Struct(self), (size_t)NUM2SIZET(rb_index)));
|
|
225
434
|
}
|
|
226
435
|
|
|
436
|
+
/* call-seq: geometric_center -> Vector2
|
|
437
|
+
*
|
|
438
|
+
* Returns the local position of the shape's geometric center.
|
|
439
|
+
*
|
|
440
|
+
* @return [Vector2] the local position of the shape's geometric center
|
|
441
|
+
*/
|
|
227
442
|
static VALUE RectangleShape_get_geometric_center(VALUE self) {
|
|
228
443
|
return vec2f_to_rb(sfRectangleShape_getGeometricCenter(Get_RectangleShape_Struct(self)));
|
|
229
444
|
}
|
|
230
445
|
|
|
446
|
+
/* call-seq: local_bounds -> Rect
|
|
447
|
+
*
|
|
448
|
+
* Returns the bounding box in local (untransformed) coordinates.
|
|
449
|
+
*
|
|
450
|
+
* @return [Rect] the bounding box in local (untransformed) coordinates
|
|
451
|
+
*/
|
|
231
452
|
static VALUE RectangleShape_get_local_bounds(VALUE self) {
|
|
232
453
|
return rect_to_rb(sfRectangleShape_getLocalBounds(Get_RectangleShape_Struct(self)));
|
|
233
454
|
}
|
|
234
455
|
|
|
456
|
+
/* call-seq: global_bounds -> Rect
|
|
457
|
+
*
|
|
458
|
+
* Returns the bounding box after the transform is applied.
|
|
459
|
+
*
|
|
460
|
+
* @return [Rect] the bounding box after transform is applied
|
|
461
|
+
*/
|
|
235
462
|
static VALUE RectangleShape_get_global_bounds(VALUE self) {
|
|
236
463
|
return rect_to_rb(sfRectangleShape_getGlobalBounds(Get_RectangleShape_Struct(self)));
|
|
237
464
|
}
|
|
238
465
|
|
|
466
|
+
/* call-seq:
|
|
467
|
+
* draw(target, state) -> nil
|
|
468
|
+
*
|
|
469
|
+
* Draws the object onto +target+ using the given render +state+.
|
|
470
|
+
*
|
|
471
|
+
* @return [nil]
|
|
472
|
+
*/
|
|
239
473
|
static VALUE RectangleShape_draw(VALUE self, VALUE rb_target, VALUE rb_state) {
|
|
240
|
-
|
|
241
|
-
raise_invalid_argument_class(Get_Klass_Target());
|
|
242
|
-
}
|
|
474
|
+
TargetView view = Get_RenderTarget_View(rb_target);
|
|
243
475
|
|
|
244
476
|
if (!rb_obj_is_kind_of(rb_state, Get_Klass_RenderState())) {
|
|
245
477
|
raise_invalid_argument_class(Get_Klass_RenderState());
|
|
246
478
|
}
|
|
247
479
|
|
|
248
|
-
TARGET_DRAW(
|
|
249
|
-
|
|
250
|
-
Get_RenderState_Struct(rb_state));
|
|
480
|
+
TARGET_DRAW(view, sfRenderWindow_drawRectangleShape, sfRenderTexture_drawRectangleShape,
|
|
481
|
+
Get_RectangleShape_Struct(self), Get_RenderState_Struct(rb_state));
|
|
251
482
|
|
|
252
483
|
return Qnil;
|
|
253
484
|
}
|
|
254
485
|
|
|
255
|
-
|
|
256
|
-
|
|
486
|
+
/* Document-class: SFML::RectangleShape
|
|
487
|
+
* A rectangle shape, drawable, transformable and stylable like the other
|
|
488
|
+
* SFML shapes. Includes Drawable.
|
|
489
|
+
*
|
|
490
|
+
* @!attribute size
|
|
491
|
+
* The object's size.
|
|
492
|
+
* @return [Vector2]
|
|
493
|
+
* @!attribute position
|
|
494
|
+
* The object's position.
|
|
495
|
+
* @return [Vector2]
|
|
496
|
+
* @!attribute rotation
|
|
497
|
+
* The object's rotation, in degrees.
|
|
498
|
+
* @return [Float]
|
|
499
|
+
* @!attribute scale
|
|
500
|
+
* The object's scale factors.
|
|
501
|
+
* @return [Vector2]
|
|
502
|
+
* @!attribute origin
|
|
503
|
+
* The object's origin.
|
|
504
|
+
* @return [Vector2]
|
|
505
|
+
* @!attribute fill_color
|
|
506
|
+
* The object's fill color.
|
|
507
|
+
* @return [Color]
|
|
508
|
+
* @!attribute outline_color
|
|
509
|
+
* The object's outline color.
|
|
510
|
+
* @return [Color]
|
|
511
|
+
* @!attribute outline_thickness
|
|
512
|
+
* The object's outline thickness.
|
|
513
|
+
* @return [Float]
|
|
514
|
+
* @!attribute texture
|
|
515
|
+
* The object's texture, or +nil+ if it has none.
|
|
516
|
+
* @return [Texture, nil]
|
|
517
|
+
* @!attribute texture_rect
|
|
518
|
+
* The sub-rectangle of the texture displayed on the object.
|
|
519
|
+
* @return [Rect]
|
|
520
|
+
*/
|
|
521
|
+
void Init_RectangleShape(VALUE rb_mSFML) {
|
|
522
|
+
rb_cRectangleShape = rb_define_class_under(rb_mSFML, "RectangleShape", rb_cObject);
|
|
523
|
+
|
|
524
|
+
rb_define_alloc_func(rb_cRectangleShape, RectangleShape_alloc);
|
|
257
525
|
|
|
258
526
|
rb_include_module(rb_cRectangleShape, Get_Module_Drawable());
|
|
259
527
|
|
|
260
|
-
|
|
528
|
+
rb_define_method(rb_cRectangleShape, "initialize", RectangleShape_initialize, -1);
|
|
261
529
|
|
|
262
530
|
rb_define_method(rb_cRectangleShape, "copy", RectangleShape_copy, 0);
|
|
263
531
|
|
|
@@ -268,16 +536,19 @@ void Init_RectangleShape(VALUE rb_module) {
|
|
|
268
536
|
rb_define_method(rb_cRectangleShape, "origin", RectangleShape_get_origin, 0);
|
|
269
537
|
rb_define_method(rb_cRectangleShape, "fill_color", RectangleShape_get_fill_color, 0);
|
|
270
538
|
rb_define_method(rb_cRectangleShape, "outline_color", RectangleShape_get_outline_color, 0);
|
|
271
|
-
rb_define_method(rb_cRectangleShape, "outline_thickness", RectangleShape_get_outline_thickness,
|
|
539
|
+
rb_define_method(rb_cRectangleShape, "outline_thickness", RectangleShape_get_outline_thickness,
|
|
540
|
+
0);
|
|
272
541
|
rb_define_method(rb_cRectangleShape, "texture", RectangleShape_get_texture, 0);
|
|
273
542
|
rb_define_method(rb_cRectangleShape, "texture_rect", RectangleShape_get_texture_rect, 0);
|
|
274
543
|
rb_define_method(rb_cRectangleShape, "point_count", RectangleShape_get_point_count, 0);
|
|
275
544
|
rb_define_method(rb_cRectangleShape, "point", RectangleShape_get_point, 1);
|
|
276
|
-
rb_define_method(rb_cRectangleShape, "geometric_center", RectangleShape_get_geometric_center,
|
|
545
|
+
rb_define_method(rb_cRectangleShape, "geometric_center", RectangleShape_get_geometric_center,
|
|
546
|
+
0);
|
|
277
547
|
rb_define_method(rb_cRectangleShape, "local_bounds", RectangleShape_get_local_bounds, 0);
|
|
278
548
|
rb_define_method(rb_cRectangleShape, "global_bounds", RectangleShape_get_global_bounds, 0);
|
|
279
549
|
rb_define_method(rb_cRectangleShape, "transform", RectangleShape_get_transform, 0);
|
|
280
|
-
rb_define_method(rb_cRectangleShape, "inverse_transform", RectangleShape_get_inverse_transform,
|
|
550
|
+
rb_define_method(rb_cRectangleShape, "inverse_transform", RectangleShape_get_inverse_transform,
|
|
551
|
+
0);
|
|
281
552
|
rb_define_method(rb_cRectangleShape, "matrix", RectangleShape_get_transform, 0);
|
|
282
553
|
|
|
283
554
|
rb_define_method(rb_cRectangleShape, "size=", RectangleShape_set_size, 1);
|
|
@@ -287,7 +558,8 @@ void Init_RectangleShape(VALUE rb_module) {
|
|
|
287
558
|
rb_define_method(rb_cRectangleShape, "origin=", RectangleShape_set_origin, 1);
|
|
288
559
|
rb_define_method(rb_cRectangleShape, "fill_color=", RectangleShape_set_fill_color, 1);
|
|
289
560
|
rb_define_method(rb_cRectangleShape, "outline_color=", RectangleShape_set_outline_color, 1);
|
|
290
|
-
rb_define_method(rb_cRectangleShape, "outline_thickness=", RectangleShape_set_outline_thickness,
|
|
561
|
+
rb_define_method(rb_cRectangleShape, "outline_thickness=", RectangleShape_set_outline_thickness,
|
|
562
|
+
1);
|
|
291
563
|
rb_define_method(rb_cRectangleShape, "texture=", RectangleShape_set_texture, 1);
|
|
292
564
|
rb_define_method(rb_cRectangleShape, "texture_rect=", RectangleShape_set_texture_rect, 1);
|
|
293
565
|
|