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/polygon.c
CHANGED
|
@@ -15,39 +15,38 @@
|
|
|
15
15
|
#include "core/macros.h"
|
|
16
16
|
|
|
17
17
|
typedef struct {
|
|
18
|
-
sfConvexShape
|
|
18
|
+
sfConvexShape* shape;
|
|
19
19
|
VALUE rb_texture;
|
|
20
20
|
} ConvexShape;
|
|
21
21
|
|
|
22
22
|
static VALUE rb_cConvexShape;
|
|
23
23
|
|
|
24
|
-
static void ConvexShape_mark(void
|
|
25
|
-
rb_gc_mark(((ConvexShape
|
|
24
|
+
static void ConvexShape_mark(void* ptr) {
|
|
25
|
+
rb_gc_mark(((ConvexShape*)ptr)->rb_texture);
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
static void ConvexShape_free(void
|
|
29
|
-
sfConvexShape_destroy(((ConvexShape
|
|
28
|
+
static void ConvexShape_free(void* ptr) {
|
|
29
|
+
sfConvexShape_destroy(((ConvexShape*)ptr)->shape);
|
|
30
30
|
free(ptr);
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
static const rb_data_type_t ConvexShape_data_type = {
|
|
34
34
|
.wrap_struct_name = "SFML::ConvexShape",
|
|
35
35
|
.function = {.dmark = ConvexShape_mark, .dfree = ConvexShape_free, .dsize = NULL},
|
|
36
|
-
.flags = RUBY_TYPED_FREE_IMMEDIATELY
|
|
37
|
-
};
|
|
36
|
+
.flags = RUBY_TYPED_FREE_IMMEDIATELY};
|
|
38
37
|
|
|
39
|
-
static ConvexShape
|
|
40
|
-
ConvexShape
|
|
38
|
+
static ConvexShape* Get_ConvexShape(VALUE self) {
|
|
39
|
+
ConvexShape* ptr;
|
|
41
40
|
TypedData_Get_Struct(self, ConvexShape, &ConvexShape_data_type, ptr);
|
|
42
41
|
return ptr;
|
|
43
42
|
}
|
|
44
43
|
|
|
45
|
-
static sfConvexShape
|
|
44
|
+
static sfConvexShape* Get_ConvexShape_Struct(VALUE self) {
|
|
46
45
|
return Get_ConvexShape(self)->shape;
|
|
47
46
|
}
|
|
48
47
|
|
|
49
|
-
static VALUE ConvexShape_wrap(VALUE klass, sfConvexShape
|
|
50
|
-
ConvexShape
|
|
48
|
+
static VALUE ConvexShape_wrap(VALUE klass, sfConvexShape* shape) {
|
|
49
|
+
ConvexShape* ptr;
|
|
51
50
|
|
|
52
51
|
if (shape == NULL) {
|
|
53
52
|
rb_raise(rb_eRuntimeError, "failed to create convex shape");
|
|
@@ -60,25 +59,38 @@ static VALUE ConvexShape_wrap(VALUE klass, sfConvexShape *shape) {
|
|
|
60
59
|
return TypedData_Wrap_Struct(klass, &ConvexShape_data_type, ptr);
|
|
61
60
|
}
|
|
62
61
|
|
|
63
|
-
|
|
64
|
-
|
|
62
|
+
/* call-seq:
|
|
63
|
+
* ConvexShape.new(point_count = 0) -> ConvexShape
|
|
64
|
+
*
|
|
65
|
+
* Creates a convex shape with room for at least +point_count+ points.
|
|
66
|
+
*
|
|
67
|
+
* @return [ConvexShape]
|
|
68
|
+
*/
|
|
69
|
+
static VALUE ConvexShape_new(int argc, VALUE* argv, VALUE klass) {
|
|
70
|
+
sfConvexShape* shape = sfConvexShape_create();
|
|
65
71
|
VALUE rb_point_count;
|
|
66
72
|
|
|
67
73
|
rb_scan_args(argc, argv, "01", &rb_point_count);
|
|
68
74
|
|
|
69
75
|
if (!NIL_P(rb_point_count)) {
|
|
70
|
-
sfConvexShape_setPointCount(shape, (size_t)
|
|
76
|
+
sfConvexShape_setPointCount(shape, (size_t)NUM2SIZET(rb_point_count));
|
|
71
77
|
}
|
|
72
78
|
|
|
73
79
|
return ConvexShape_wrap(klass, shape);
|
|
74
80
|
}
|
|
75
81
|
|
|
82
|
+
/* call-seq: copy -> ConvexShape
|
|
83
|
+
*
|
|
84
|
+
* Returns a deep copy of the object.
|
|
85
|
+
*
|
|
86
|
+
* @return [ConvexShape] an independent copy, including its texture reference
|
|
87
|
+
*/
|
|
76
88
|
static VALUE ConvexShape_copy(VALUE self) {
|
|
77
|
-
ConvexShape
|
|
89
|
+
ConvexShape* ptr = Get_ConvexShape(self);
|
|
78
90
|
VALUE copy = ConvexShape_wrap(Get_Klass_ConvexShape(), sfConvexShape_copy(ptr->shape));
|
|
79
91
|
|
|
80
92
|
if (!NIL_P(ptr->rb_texture)) {
|
|
81
|
-
ConvexShape
|
|
93
|
+
ConvexShape* copy_ptr = Get_ConvexShape(copy);
|
|
82
94
|
|
|
83
95
|
copy_ptr->rb_texture = ptr->rb_texture;
|
|
84
96
|
sfConvexShape_setTexture(copy_ptr->shape, Get_Texture_Struct(ptr->rb_texture), false);
|
|
@@ -87,112 +99,283 @@ static VALUE ConvexShape_copy(VALUE self) {
|
|
|
87
99
|
return copy;
|
|
88
100
|
}
|
|
89
101
|
|
|
102
|
+
/* call-seq: point_count -> Integer
|
|
103
|
+
*
|
|
104
|
+
* Returns the number of points composing the shape.
|
|
105
|
+
*
|
|
106
|
+
* @return [Integer]
|
|
107
|
+
*/
|
|
90
108
|
static VALUE ConvexShape_get_point_count(VALUE self) {
|
|
91
109
|
return SIZET2NUM(sfConvexShape_getPointCount(Get_ConvexShape_Struct(self)));
|
|
92
110
|
}
|
|
93
111
|
|
|
112
|
+
/* call-seq:
|
|
113
|
+
* point_count=(value) -> Integer
|
|
114
|
+
*
|
|
115
|
+
* Sets the number of points composing the shape.
|
|
116
|
+
*
|
|
117
|
+
* @return [Integer] +value+
|
|
118
|
+
*/
|
|
94
119
|
static VALUE ConvexShape_set_point_count(VALUE self, VALUE rb_count) {
|
|
95
|
-
sfConvexShape_setPointCount(Get_ConvexShape_Struct(self), (size_t)
|
|
120
|
+
sfConvexShape_setPointCount(Get_ConvexShape_Struct(self), (size_t)NUM2SIZET(rb_count));
|
|
96
121
|
return rb_count;
|
|
97
122
|
}
|
|
98
123
|
|
|
124
|
+
static size_t ConvexShape_check_index(VALUE self, VALUE rb_index) {
|
|
125
|
+
void* shape = Get_ConvexShape_Struct(self);
|
|
126
|
+
size_t index = (size_t)NUM2SIZET(rb_index);
|
|
127
|
+
size_t count = sfConvexShape_getPointCount(shape);
|
|
128
|
+
|
|
129
|
+
if (index >= count) {
|
|
130
|
+
rb_raise(rb_eIndexError, "index %zu outside of point count %zu", index, count);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
return index;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/* call-seq: point(index) -> Vector2
|
|
137
|
+
*
|
|
138
|
+
* Returns the local position of the point at +index+.
|
|
139
|
+
*
|
|
140
|
+
* @return [Vector2] the local position of the point at +index+
|
|
141
|
+
* @raise [IndexError] if +index+ is out of range
|
|
142
|
+
*/
|
|
99
143
|
static VALUE ConvexShape_get_point(VALUE self, VALUE rb_index) {
|
|
100
|
-
return vec2f_to_rb(sfConvexShape_getPoint(Get_ConvexShape_Struct(self),
|
|
144
|
+
return vec2f_to_rb(sfConvexShape_getPoint(Get_ConvexShape_Struct(self),
|
|
145
|
+
ConvexShape_check_index(self, rb_index)));
|
|
101
146
|
}
|
|
102
147
|
|
|
148
|
+
/* call-seq: set_point(index, point) -> Vector2
|
|
149
|
+
*
|
|
150
|
+
* Sets the position of the point at +index+.
|
|
151
|
+
*
|
|
152
|
+
* @return [Vector2] +point+
|
|
153
|
+
* @raise [IndexError] if +index+ is out of range
|
|
154
|
+
*/
|
|
103
155
|
static VALUE ConvexShape_set_point(VALUE self, VALUE rb_index, VALUE rb_point) {
|
|
104
|
-
sfConvexShape_setPoint(Get_ConvexShape_Struct(self), (
|
|
156
|
+
sfConvexShape_setPoint(Get_ConvexShape_Struct(self), ConvexShape_check_index(self, rb_index),
|
|
157
|
+
vec2f_from_rb(rb_point));
|
|
105
158
|
return rb_point;
|
|
106
159
|
}
|
|
107
160
|
|
|
161
|
+
/* call-seq: position -> Vector2
|
|
162
|
+
*
|
|
163
|
+
* Returns the object's position.
|
|
164
|
+
*
|
|
165
|
+
* @return [Vector2]
|
|
166
|
+
*/
|
|
108
167
|
static VALUE ConvexShape_get_position(VALUE self) {
|
|
109
168
|
return vec2f_to_rb(sfConvexShape_getPosition(Get_ConvexShape_Struct(self)));
|
|
110
169
|
}
|
|
111
170
|
|
|
171
|
+
/* call-seq:
|
|
172
|
+
* position=(value) -> Vector2
|
|
173
|
+
*
|
|
174
|
+
* Sets the object's position.
|
|
175
|
+
*
|
|
176
|
+
* @return [Vector2] +value+
|
|
177
|
+
*/
|
|
112
178
|
static VALUE ConvexShape_set_position(VALUE self, VALUE rb_position) {
|
|
113
179
|
sfConvexShape_setPosition(Get_ConvexShape_Struct(self), vec2f_from_rb(rb_position));
|
|
114
180
|
return rb_position;
|
|
115
181
|
}
|
|
116
182
|
|
|
183
|
+
/* call-seq: rotation -> Float
|
|
184
|
+
*
|
|
185
|
+
* Returns the object's rotation, in degrees.
|
|
186
|
+
*
|
|
187
|
+
* @return [Float]
|
|
188
|
+
*/
|
|
117
189
|
static VALUE ConvexShape_get_rotation(VALUE self) {
|
|
118
190
|
return DBL2NUM(sfConvexShape_getRotation(Get_ConvexShape_Struct(self)));
|
|
119
191
|
}
|
|
120
192
|
|
|
193
|
+
/* call-seq:
|
|
194
|
+
* rotation=(value) -> Float
|
|
195
|
+
*
|
|
196
|
+
* Sets the object's rotation, in degrees.
|
|
197
|
+
*
|
|
198
|
+
* @return [Float] +value+
|
|
199
|
+
*/
|
|
121
200
|
static VALUE ConvexShape_set_rotation(VALUE self, VALUE rb_rotation) {
|
|
122
201
|
sfConvexShape_setRotation(Get_ConvexShape_Struct(self), NUM2DBL(rb_rotation));
|
|
123
202
|
return rb_rotation;
|
|
124
203
|
}
|
|
125
204
|
|
|
205
|
+
/* call-seq: scale -> Vector2
|
|
206
|
+
*
|
|
207
|
+
* Returns the object's scale factors.
|
|
208
|
+
*
|
|
209
|
+
* @return [Vector2]
|
|
210
|
+
*/
|
|
126
211
|
static VALUE ConvexShape_get_scale(VALUE self) {
|
|
127
212
|
return vec2f_to_rb(sfConvexShape_getScale(Get_ConvexShape_Struct(self)));
|
|
128
213
|
}
|
|
129
214
|
|
|
215
|
+
/* call-seq:
|
|
216
|
+
* scale=(value) -> Vector2
|
|
217
|
+
*
|
|
218
|
+
* Sets the object's scale factors.
|
|
219
|
+
*
|
|
220
|
+
* @return [Vector2] +value+
|
|
221
|
+
*/
|
|
130
222
|
static VALUE ConvexShape_set_scale(VALUE self, VALUE rb_scale) {
|
|
131
223
|
sfConvexShape_setScale(Get_ConvexShape_Struct(self), vec2f_from_rb(rb_scale));
|
|
132
224
|
return rb_scale;
|
|
133
225
|
}
|
|
134
226
|
|
|
227
|
+
/* call-seq: origin -> Vector2
|
|
228
|
+
*
|
|
229
|
+
* Returns the object's origin.
|
|
230
|
+
*
|
|
231
|
+
* @return [Vector2]
|
|
232
|
+
*/
|
|
135
233
|
static VALUE ConvexShape_get_origin(VALUE self) {
|
|
136
234
|
return vec2f_to_rb(sfConvexShape_getOrigin(Get_ConvexShape_Struct(self)));
|
|
137
235
|
}
|
|
138
236
|
|
|
237
|
+
/* call-seq:
|
|
238
|
+
* origin=(value) -> Vector2
|
|
239
|
+
*
|
|
240
|
+
* Sets the object's origin.
|
|
241
|
+
*
|
|
242
|
+
* @return [Vector2] +value+
|
|
243
|
+
*/
|
|
139
244
|
static VALUE ConvexShape_set_origin(VALUE self, VALUE rb_origin) {
|
|
140
245
|
sfConvexShape_setOrigin(Get_ConvexShape_Struct(self), vec2f_from_rb(rb_origin));
|
|
141
246
|
return rb_origin;
|
|
142
247
|
}
|
|
143
248
|
|
|
249
|
+
/* call-seq: move(offset) -> self
|
|
250
|
+
*
|
|
251
|
+
* Moves the object by +offset+.
|
|
252
|
+
*
|
|
253
|
+
* @return [self]
|
|
254
|
+
*/
|
|
144
255
|
static VALUE ConvexShape_move(VALUE self, VALUE rb_offset) {
|
|
145
256
|
sfConvexShape_move(Get_ConvexShape_Struct(self), vec2f_from_rb(rb_offset));
|
|
146
257
|
return self;
|
|
147
258
|
}
|
|
148
259
|
|
|
260
|
+
/* call-seq: rotate(angle) -> self
|
|
261
|
+
*
|
|
262
|
+
* Rotates the object by +angle+ degrees.
|
|
263
|
+
*
|
|
264
|
+
* @return [self]
|
|
265
|
+
*/
|
|
149
266
|
static VALUE ConvexShape_rotate(VALUE self, VALUE rb_angle) {
|
|
150
267
|
sfConvexShape_rotate(Get_ConvexShape_Struct(self), NUM2DBL(rb_angle));
|
|
151
268
|
return self;
|
|
152
269
|
}
|
|
153
270
|
|
|
271
|
+
/* call-seq:
|
|
272
|
+
* scale!(factors) -> self
|
|
273
|
+
*
|
|
274
|
+
* Scales the object by +factors+ relative to its current scale.
|
|
275
|
+
*
|
|
276
|
+
* @return [self]
|
|
277
|
+
*/
|
|
154
278
|
static VALUE ConvexShape_scale(VALUE self, VALUE rb_factors) {
|
|
155
279
|
sfConvexShape_scale(Get_ConvexShape_Struct(self), vec2f_from_rb(rb_factors));
|
|
156
280
|
return self;
|
|
157
281
|
}
|
|
158
282
|
|
|
283
|
+
/* call-seq: transform -> Array
|
|
284
|
+
*
|
|
285
|
+
* Also available as #matrix.
|
|
286
|
+
*
|
|
287
|
+
* @return [Array] the 3x3 row-major transform matrix
|
|
288
|
+
*/
|
|
159
289
|
static VALUE ConvexShape_get_transform(VALUE self) {
|
|
160
290
|
return Transform_MatrixToArray(sfConvexShape_getTransform(Get_ConvexShape_Struct(self)).matrix);
|
|
161
291
|
}
|
|
162
292
|
|
|
293
|
+
/* call-seq: inverse_transform -> Array
|
|
294
|
+
*
|
|
295
|
+
* Returns the 3x3 row-major inverse of the object's transform matrix.
|
|
296
|
+
*
|
|
297
|
+
* @return [Array] the 3x3 row-major inverse transform matrix
|
|
298
|
+
*/
|
|
163
299
|
static VALUE ConvexShape_get_inverse_transform(VALUE self) {
|
|
164
|
-
return Transform_MatrixToArray(
|
|
300
|
+
return Transform_MatrixToArray(
|
|
301
|
+
sfConvexShape_getInverseTransform(Get_ConvexShape_Struct(self)).matrix);
|
|
165
302
|
}
|
|
166
303
|
|
|
304
|
+
/* call-seq: fill_color -> Color
|
|
305
|
+
*
|
|
306
|
+
* Returns the shape's fill color.
|
|
307
|
+
*
|
|
308
|
+
* @return [Color]
|
|
309
|
+
*/
|
|
167
310
|
static VALUE ConvexShape_get_fill_color(VALUE self) {
|
|
168
311
|
return color_to_rb(sfConvexShape_getFillColor(Get_ConvexShape_Struct(self)));
|
|
169
312
|
}
|
|
170
313
|
|
|
314
|
+
/* call-seq:
|
|
315
|
+
* fill_color=(value) -> Color
|
|
316
|
+
*
|
|
317
|
+
* Sets the shape's fill color.
|
|
318
|
+
*
|
|
319
|
+
* @return [Color] +value+
|
|
320
|
+
*/
|
|
171
321
|
static VALUE ConvexShape_set_fill_color(VALUE self, VALUE rb_color) {
|
|
172
322
|
sfConvexShape_setFillColor(Get_ConvexShape_Struct(self), color_from_rb(rb_color));
|
|
173
323
|
return rb_color;
|
|
174
324
|
}
|
|
175
325
|
|
|
326
|
+
/* call-seq: outline_color -> Color
|
|
327
|
+
*
|
|
328
|
+
* Returns the shape's outline color.
|
|
329
|
+
*
|
|
330
|
+
* @return [Color]
|
|
331
|
+
*/
|
|
176
332
|
static VALUE ConvexShape_get_outline_color(VALUE self) {
|
|
177
333
|
return color_to_rb(sfConvexShape_getOutlineColor(Get_ConvexShape_Struct(self)));
|
|
178
334
|
}
|
|
179
335
|
|
|
336
|
+
/* call-seq:
|
|
337
|
+
* outline_color=(value) -> Color
|
|
338
|
+
*
|
|
339
|
+
* Sets the shape's outline color.
|
|
340
|
+
*
|
|
341
|
+
* @return [Color] +value+
|
|
342
|
+
*/
|
|
180
343
|
static VALUE ConvexShape_set_outline_color(VALUE self, VALUE rb_color) {
|
|
181
344
|
sfConvexShape_setOutlineColor(Get_ConvexShape_Struct(self), color_from_rb(rb_color));
|
|
182
345
|
return rb_color;
|
|
183
346
|
}
|
|
184
347
|
|
|
348
|
+
/* call-seq: outline_thickness -> Float
|
|
349
|
+
*
|
|
350
|
+
* Returns the shape's outline thickness.
|
|
351
|
+
*
|
|
352
|
+
* @return [Float]
|
|
353
|
+
*/
|
|
185
354
|
static VALUE ConvexShape_get_outline_thickness(VALUE self) {
|
|
186
355
|
return DBL2NUM(sfConvexShape_getOutlineThickness(Get_ConvexShape_Struct(self)));
|
|
187
356
|
}
|
|
188
357
|
|
|
358
|
+
/* call-seq:
|
|
359
|
+
* outline_thickness=(value) -> Float
|
|
360
|
+
*
|
|
361
|
+
* Sets the shape's outline thickness.
|
|
362
|
+
*
|
|
363
|
+
* @return [Float] +value+
|
|
364
|
+
*/
|
|
189
365
|
static VALUE ConvexShape_set_outline_thickness(VALUE self, VALUE rb_thickness) {
|
|
190
366
|
sfConvexShape_setOutlineThickness(Get_ConvexShape_Struct(self), NUM2DBL(rb_thickness));
|
|
191
367
|
return rb_thickness;
|
|
192
368
|
}
|
|
193
369
|
|
|
370
|
+
/* call-seq:
|
|
371
|
+
* texture=(value) -> Texture or nil
|
|
372
|
+
*
|
|
373
|
+
* Sets the object's texture.
|
|
374
|
+
*
|
|
375
|
+
* @return [Texture, nil] +value+
|
|
376
|
+
*/
|
|
194
377
|
static VALUE ConvexShape_set_texture(VALUE self, VALUE rb_texture) {
|
|
195
|
-
ConvexShape
|
|
378
|
+
ConvexShape* ptr = Get_ConvexShape(self);
|
|
196
379
|
|
|
197
380
|
if (NIL_P(rb_texture)) {
|
|
198
381
|
ptr->rb_texture = Qnil;
|
|
@@ -210,31 +393,75 @@ static VALUE ConvexShape_set_texture(VALUE self, VALUE rb_texture) {
|
|
|
210
393
|
return rb_texture;
|
|
211
394
|
}
|
|
212
395
|
|
|
396
|
+
/* call-seq: texture -> Texture or nil
|
|
397
|
+
*
|
|
398
|
+
* Returns the object's texture, or +nil+ if it has none.
|
|
399
|
+
*
|
|
400
|
+
* @return [Texture, nil]
|
|
401
|
+
*/
|
|
213
402
|
static VALUE ConvexShape_get_texture(VALUE self) {
|
|
214
403
|
return Get_ConvexShape(self)->rb_texture;
|
|
215
404
|
}
|
|
216
405
|
|
|
406
|
+
/* call-seq: texture_rect -> Rect
|
|
407
|
+
*
|
|
408
|
+
* Returns the sub-rectangle of the texture displayed on the object.
|
|
409
|
+
*
|
|
410
|
+
* @return [Rect] the sub-rectangle of the texture displayed on the shape
|
|
411
|
+
*/
|
|
217
412
|
static VALUE ConvexShape_get_texture_rect(VALUE self) {
|
|
218
413
|
return int_rect_to_rb(sfConvexShape_getTextureRect(Get_ConvexShape_Struct(self)));
|
|
219
414
|
}
|
|
220
415
|
|
|
416
|
+
/* call-seq:
|
|
417
|
+
* texture_rect=(value) -> Rect
|
|
418
|
+
*
|
|
419
|
+
* Sets the sub-rectangle of the texture displayed on the object.
|
|
420
|
+
*
|
|
421
|
+
* @return [Rect] +value+
|
|
422
|
+
*/
|
|
221
423
|
static VALUE ConvexShape_set_texture_rect(VALUE self, VALUE rb_rect) {
|
|
222
424
|
sfConvexShape_setTextureRect(Get_ConvexShape_Struct(self), int_rect_from_rb(rb_rect));
|
|
223
425
|
return rb_rect;
|
|
224
426
|
}
|
|
225
427
|
|
|
428
|
+
/* call-seq: geometric_center -> Vector2
|
|
429
|
+
*
|
|
430
|
+
* Returns the local position of the shape's geometric center.
|
|
431
|
+
*
|
|
432
|
+
* @return [Vector2] the local position of the shape's geometric center
|
|
433
|
+
*/
|
|
226
434
|
static VALUE ConvexShape_get_geometric_center(VALUE self) {
|
|
227
435
|
return vec2f_to_rb(sfConvexShape_getGeometricCenter(Get_ConvexShape_Struct(self)));
|
|
228
436
|
}
|
|
229
437
|
|
|
438
|
+
/* call-seq: local_bounds -> Rect
|
|
439
|
+
*
|
|
440
|
+
* Returns the bounding box in local (untransformed) coordinates.
|
|
441
|
+
*
|
|
442
|
+
* @return [Rect] the bounding box in local (untransformed) coordinates
|
|
443
|
+
*/
|
|
230
444
|
static VALUE ConvexShape_get_local_bounds(VALUE self) {
|
|
231
445
|
return rect_to_rb(sfConvexShape_getLocalBounds(Get_ConvexShape_Struct(self)));
|
|
232
446
|
}
|
|
233
447
|
|
|
448
|
+
/* call-seq: global_bounds -> Rect
|
|
449
|
+
*
|
|
450
|
+
* Returns the bounding box after the transform is applied.
|
|
451
|
+
*
|
|
452
|
+
* @return [Rect] the bounding box after transform is applied
|
|
453
|
+
*/
|
|
234
454
|
static VALUE ConvexShape_get_global_bounds(VALUE self) {
|
|
235
455
|
return rect_to_rb(sfConvexShape_getGlobalBounds(Get_ConvexShape_Struct(self)));
|
|
236
456
|
}
|
|
237
457
|
|
|
458
|
+
/* call-seq:
|
|
459
|
+
* draw(target, state) -> nil
|
|
460
|
+
*
|
|
461
|
+
* Draws the object onto +target+ using the given render +state+.
|
|
462
|
+
*
|
|
463
|
+
* @return [nil]
|
|
464
|
+
*/
|
|
238
465
|
static VALUE ConvexShape_draw(VALUE self, VALUE rb_target, VALUE rb_state) {
|
|
239
466
|
if (!rb_obj_is_kind_of(rb_target, Get_Klass_Target())) {
|
|
240
467
|
raise_invalid_argument_class(Get_Klass_Target());
|
|
@@ -244,14 +471,54 @@ static VALUE ConvexShape_draw(VALUE self, VALUE rb_target, VALUE rb_state) {
|
|
|
244
471
|
raise_invalid_argument_class(Get_Klass_RenderState());
|
|
245
472
|
}
|
|
246
473
|
|
|
247
|
-
TARGET_DRAW(Get_Target_Struct(rb_target), sfRenderWindow_drawConvexShape,
|
|
248
|
-
Get_ConvexShape_Struct(self),
|
|
474
|
+
TARGET_DRAW(Get_Target_Struct(rb_target), sfRenderWindow_drawConvexShape,
|
|
475
|
+
sfRenderTexture_drawConvexShape, Get_ConvexShape_Struct(self),
|
|
476
|
+
Get_RenderState_Struct(rb_state));
|
|
249
477
|
|
|
250
478
|
return Qnil;
|
|
251
479
|
}
|
|
252
480
|
|
|
253
|
-
|
|
254
|
-
|
|
481
|
+
/* Document-class: SFML::ConvexShape
|
|
482
|
+
* A convex polygon shape defined by an arbitrary set of points, drawable,
|
|
483
|
+
* transformable and stylable like the other SFML shapes. Includes
|
|
484
|
+
* Drawable.
|
|
485
|
+
*
|
|
486
|
+
* The polygon must remain convex; passing points that describe a concave
|
|
487
|
+
* shape produces undefined rendering.
|
|
488
|
+
*
|
|
489
|
+
* @!attribute point_count
|
|
490
|
+
* The number of points composing the shape.
|
|
491
|
+
* @return [Integer]
|
|
492
|
+
* @!attribute position
|
|
493
|
+
* The object's position.
|
|
494
|
+
* @return [Vector2]
|
|
495
|
+
* @!attribute rotation
|
|
496
|
+
* The object's rotation, in degrees.
|
|
497
|
+
* @return [Float]
|
|
498
|
+
* @!attribute scale
|
|
499
|
+
* The object's scale factors.
|
|
500
|
+
* @return [Vector2]
|
|
501
|
+
* @!attribute origin
|
|
502
|
+
* The object's origin.
|
|
503
|
+
* @return [Vector2]
|
|
504
|
+
* @!attribute fill_color
|
|
505
|
+
* The object's fill color.
|
|
506
|
+
* @return [Color]
|
|
507
|
+
* @!attribute outline_color
|
|
508
|
+
* The object's outline color.
|
|
509
|
+
* @return [Color]
|
|
510
|
+
* @!attribute outline_thickness
|
|
511
|
+
* The object's outline thickness.
|
|
512
|
+
* @return [Float]
|
|
513
|
+
* @!attribute texture
|
|
514
|
+
* The object's texture, or +nil+ if it has none.
|
|
515
|
+
* @return [Texture, nil]
|
|
516
|
+
* @!attribute texture_rect
|
|
517
|
+
* The sub-rectangle of the texture displayed on the object.
|
|
518
|
+
* @return [Rect]
|
|
519
|
+
*/
|
|
520
|
+
void Init_ConvexShape(VALUE rb_mSFML) {
|
|
521
|
+
rb_cConvexShape = rb_define_class_under(rb_mSFML, "ConvexShape", rb_cObject);
|
|
255
522
|
|
|
256
523
|
rb_include_module(rb_cConvexShape, Get_Module_Drawable());
|
|
257
524
|
|