cglm 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,365 @@
1
+ #include "rb_cglm.h"
2
+
3
+ /* call-seq: aspect => Numeric */
4
+ VALUE rb_cglm_cam_decomp_aspect(VALUE self) {
5
+ return DBL2NUM(glm_persp_aspect(VAL2MAT4(self)));
6
+ }
7
+
8
+ /* call-seq: fovy => Numeric */
9
+ VALUE rb_cglm_cam_decomp_fovy(VALUE self) {
10
+ return DBL2NUM(glm_persp_fovy(VAL2MAT4(self)));
11
+ }
12
+
13
+ /* call-seq: left_and_right => Array */
14
+ VALUE rb_cglm_cam_decomp_left_and_right(VALUE self) {
15
+ float left, right;
16
+ glm_persp_decomp_x(VAL2MAT4(self), &left, &right);
17
+ return rb_ary_new_from_args(2, DBL2NUM(left), DBL2NUM(right));
18
+ }
19
+
20
+ /* call-seq: sizes([fovy]) => Hash
21
+ *
22
+ * Returns the sizes of the near and far planes of this perspective
23
+ * projection. The return value has the following format:
24
+ *
25
+ * { near: [width, height], far: [width, height] }
26
+ *
27
+ * If `fovy` is omitted, it will be decomposed from the current matrix.
28
+ */
29
+ VALUE rb_cglm_cam_sizes(int argc, VALUE *argv, VALUE self) {
30
+ VALUE fovy = Qnil;
31
+ if (argc == 0) fovy = rb_cglm_cam_decomp_fovy(self);
32
+ else fovy = argv[0];
33
+ vec4 out;
34
+ glm_persp_sizes(VAL2MAT4(self), NUM2FLT(fovy), out);
35
+ VALUE n = rb_ary_new_from_args(2, DBL2NUM(out[0]), DBL2NUM(out[1]));
36
+ VALUE f = rb_ary_new_from_args(2, DBL2NUM(out[2]), DBL2NUM(out[3]));
37
+ VALUE dest = rb_hash_new();
38
+ rb_hash_aset(dest, ID2SYM(rb_intern("near")), n);
39
+ rb_hash_aset(dest, ID2SYM(rb_intern("far")), f);
40
+ return dest;
41
+ }
42
+
43
+ /* call-seq: top_and_bottom => Array */
44
+ VALUE rb_cglm_cam_decomp_top_and_bottom(VALUE self) {
45
+ float top, bottom;
46
+ glm_persp_decomp_y(VAL2MAT4(self), &top, &bottom);
47
+ return rb_ary_new_from_args(2, DBL2NUM(top), DBL2NUM(bottom));
48
+ }
49
+
50
+ /* call-seq: near_and_far => Array */
51
+ VALUE rb_cglm_cam_decomp_near_and_far(VALUE self) {
52
+ float n, f;
53
+ glm_persp_decomp_z(VAL2MAT4(self), &n, &f);
54
+ return rb_ary_new_from_args(2, DBL2NUM(n), DBL2NUM(f));
55
+ }
56
+
57
+ /* call-seq: left => Numeric */
58
+ VALUE rb_cglm_cam_decomp_left(VALUE self) {
59
+ float left, right;
60
+ glm_persp_decomp_x(VAL2MAT4(self), &left, &right);
61
+ return DBL2NUM(left);
62
+ }
63
+
64
+ /* call-seq: right => Numeric */
65
+ VALUE rb_cglm_cam_decomp_right(VALUE self) {
66
+ float left, right;
67
+ glm_persp_decomp_x(VAL2MAT4(self), &left, &right);
68
+ return DBL2NUM(right);
69
+ }
70
+
71
+ /* call-seq: top => Numeric */
72
+ VALUE rb_cglm_cam_decomp_top(VALUE self) {
73
+ float top, bottom;
74
+ glm_persp_decomp_y(VAL2MAT4(self), &top, &bottom);
75
+ return DBL2NUM(top);
76
+ }
77
+
78
+ /* call-seq: bottom => Numeric */
79
+ VALUE rb_cglm_cam_decomp_bottom(VALUE self) {
80
+ float top, bottom;
81
+ glm_persp_decomp_y(VAL2MAT4(self), &top, &bottom);
82
+ return DBL2NUM(bottom);
83
+ }
84
+
85
+ /* call-seq: near => Numeric */
86
+ VALUE rb_cglm_cam_decomp_near(VALUE self) {
87
+ float n;
88
+ glm_persp_decomp_near(VAL2MAT4(self), &n);
89
+ return DBL2NUM(n);
90
+ }
91
+
92
+ /* call-seq: far => Numeric */
93
+ VALUE rb_cglm_cam_decomp_far(VALUE self) {
94
+ float f;
95
+ glm_persp_decomp_far(VAL2MAT4(self), &f);
96
+ return DBL2NUM(f);
97
+ }
98
+
99
+
100
+ /*
101
+ * call-seq: frustum() => Hash
102
+ *
103
+ * Decomposes this perspective matrix into a hash containing the 6 frustum
104
+ * values: `:near`, `:far`, `:top`, `:bottom`, `:left`, and `:right`.
105
+ */
106
+ VALUE rb_cglm_cam_frustum_decomp(VALUE self) {
107
+ VALUE hash = rb_hash_new();
108
+ float left, top, right, bottom, n, f;
109
+ glm_persp_decomp(VAL2MAT4(self), &n, &f, &top, &bottom, &left, &right);
110
+ rb_hash_aset(hash, ID2SYM(rb_intern("near")), DBL2NUM(n));
111
+ rb_hash_aset(hash, ID2SYM(rb_intern("far")), DBL2NUM(f));
112
+ rb_hash_aset(hash, ID2SYM(rb_intern("left")), DBL2NUM(left));
113
+ rb_hash_aset(hash, ID2SYM(rb_intern("right")), DBL2NUM(right));
114
+ rb_hash_aset(hash, ID2SYM(rb_intern("bottom")), DBL2NUM(bottom));
115
+ rb_hash_aset(hash, ID2SYM(rb_intern("top")), DBL2NUM(top));
116
+ return hash;
117
+ }
118
+
119
+ /* call-seq: look(eye, direction[, up, dest]) => dest | new Mat4
120
+ *
121
+ * Convenience wrapper for {look_at} for if you only have direction and not
122
+ * the target position.
123
+ *
124
+ * If `up` is omitted (or nil), it is assumed that you don't care what it is,
125
+ * and one will be computed for you.
126
+ *
127
+ * Note: The `up` vector must not be parallel to the line of sight from the
128
+ * eye point to the reference point.
129
+ */
130
+ VALUE rb_cglm_cam_look(int argc, VALUE *argv, VALUE self) {
131
+ VALUE dest, eye, dir, up;
132
+ rb_scan_args(argc, argv, "31", &eye, &dir, &up, &dest);
133
+ if (NIL_P(dest)) dest = MAT4_NEW(ALLOC_MAT4);
134
+ if (NIL_P(up))
135
+ glm_look_anyup(VAL2VEC3(eye), VAL2VEC3(dir), VAL2MAT4(dest));
136
+ else
137
+ glm_look(VAL2VEC3(eye), VAL2VEC3(dir), VAL2VEC3(up), VAL2MAT4(dest));
138
+ return dest;
139
+ }
140
+
141
+ /* call-seq: look_at(eye, target_position, up[, dest]) => dest | new Mat4
142
+ *
143
+ * Sets up a view matrix.
144
+ *
145
+ * NOTE: The `up` vector must not be parallel to the line of sight from the
146
+ * eye point to the reference point.
147
+ */
148
+ VALUE rb_cglm_cam_look_at(int argc, VALUE *argv, VALUE self) {
149
+ VALUE dest, eye, center, up;
150
+ rb_scan_args(argc, argv, "31", &eye, &center, &up, &dest);
151
+ if (NIL_P(dest)) dest = MAT4_NEW(ALLOC_MAT4);
152
+ glm_lookat(VAL2VEC3(eye), VAL2VEC3(center), VAL2VEC3(up), VAL2MAT4(dest));
153
+ return dest;
154
+ }
155
+
156
+ /* call-seq: perspective_resize!(aspect) => self
157
+ *
158
+ * Resizes this perspective matrix by the given aspect ratio (`width / height`).
159
+ * This makes it very easy to resize the projective matrix when the window or
160
+ * viewport is changed.
161
+ */
162
+ VALUE rb_cglm_cam_perspective_resize_self(VALUE self, VALUE aspect) {
163
+ glm_perspective_resize(NUM2FLT(aspect), VAL2MAT4(self));
164
+ return self;
165
+ }
166
+
167
+ /* call-seq: perspective([dest], fovy: PI/4, aspect:, near: 0.1, far: 100.0) => dest | new Mat4
168
+ *
169
+ * Sets up a perspective projection matrix.
170
+ */
171
+ VALUE rb_cglm_cam_perspective(int argc, VALUE *argv, VALUE self) {
172
+ static ID kwargs_ids[4];
173
+ if (!kwargs_ids[0]) {
174
+ kwargs_ids[0] = rb_intern_const("aspect");
175
+ kwargs_ids[1] = rb_intern_const("fovy");
176
+ kwargs_ids[2] = rb_intern_const("near");
177
+ kwargs_ids[3] = rb_intern_const("far");
178
+ };
179
+ VALUE dest, kwargs[4], opts;
180
+ rb_scan_args(argc, argv, "01:", &dest, &opts);
181
+ rb_get_kwargs(opts, kwargs_ids, 1, 3, kwargs);
182
+ if (NIL_P(dest)) dest = MAT4_NEW(ALLOC_MAT4);
183
+ if (RB_TYPE_P(kwargs[1], T_UNDEF)) kwargs[1] = DBL2NUM(GLM_PI_4f);
184
+ if (RB_TYPE_P(kwargs[2], T_UNDEF)) kwargs[2] = DBL2NUM(0.1);
185
+ if (RB_TYPE_P(kwargs[3], T_UNDEF)) kwargs[3] = DBL2NUM(100.0);
186
+ glm_perspective(NUM2FLT(kwargs[1]),
187
+ NUM2FLT(kwargs[0]),
188
+ NUM2FLT(kwargs[2]),
189
+ NUM2FLT(kwargs[3]),
190
+ VAL2MAT4(dest));
191
+ return dest;
192
+ }
193
+
194
+ /* call-seq: ortho_cube(aspect, size[, dest]) => dest | new Mat4
195
+ *
196
+ * Sets up a new cubed orthographic projection matrix (it has the same size in
197
+ * all dimensions).
198
+ */
199
+ VALUE rb_cglm_cam_ortho_cube(int argc, VALUE *argv, VALUE self) {
200
+ VALUE aspect, size, dest;
201
+ rb_scan_args(argc, argv, "21", &aspect, &size, &dest);
202
+ if (NIL_P(dest)) dest = MAT4_NEW(ALLOC_MAT4);
203
+ glm_ortho_default_s(NUM2FLT(aspect), NUM2FLT(size), VAL2MAT4(dest));
204
+ return dest;
205
+ }
206
+
207
+ /* call-seq: ortho_unit(aspect[, dest]) => dest | new Mat4
208
+ *
209
+ * Sets up a unit orthographic projection matrix.
210
+ */
211
+ VALUE rb_cglm_cam_ortho_unit(int argc, VALUE *argv, VALUE self) {
212
+ VALUE aspect, dest;
213
+ rb_scan_args(argc, argv, "11", &aspect, &dest);
214
+ if (NIL_P(dest)) dest = MAT4_NEW(ALLOC_MAT4);
215
+ glm_ortho_default(NUM2FLT(aspect), VAL2MAT4(dest));
216
+ return dest;
217
+ }
218
+
219
+ /* call-seq: ortho_aabb(aabb[, dest], padding: 0, padding_z: 0) => dest | new Mat4
220
+ *
221
+ * Sets up an orthographic projection matrix using the given bounding box.
222
+ *
223
+ * If `dest` is omitted, a new Mat4 will be allocated and returned. Otherwise,
224
+ * the result will be placed into `dest` and returned.
225
+ *
226
+ * If `padding` is present and `padding_z` is omitted, then the entire projection
227
+ * will have the same padding (including near/far values). If both are present,
228
+ * the near/far values will use `padding_z` while all other values will be
229
+ * padded with `padding`.
230
+ */
231
+ VALUE rb_cglm_cam_ortho_aabb(int argc, VALUE *argv, VALUE self) {
232
+ VALUE boxv, dest, opts;
233
+ static ID kwargs_ids[2];
234
+ if (!kwargs_ids[0]) {
235
+ kwargs_ids[0] = rb_intern_const("padding");
236
+ kwargs_ids[1] = rb_intern_const("padding_z");
237
+ }
238
+ VALUE kwargs[2];
239
+ rb_scan_args(argc, argv, "11:", &boxv, &dest, &opts);
240
+ rb_get_kwargs(opts, kwargs_ids, 0, 2, kwargs);
241
+ aabb box = VAL2AABB(boxv);
242
+ if (NIL_P(dest)) dest = MAT4_NEW(ALLOC_MAT4);
243
+ if (RB_TYPE_P(kwargs[0], T_UNDEF)) {
244
+ if (RB_TYPE_P(kwargs[1], T_UNDEF)) {
245
+ glm_ortho_aabb(box.corners, VAL2MAT4(dest));
246
+ } else {
247
+ glm_ortho_aabb_pz(box.corners, NUM2FLT(kwargs[1]), VAL2MAT4(dest));
248
+ }
249
+ }
250
+ else{
251
+ if (RB_TYPE_P(kwargs[1], T_UNDEF)) {
252
+ glm_ortho_aabb_p(box.corners, NUM2FLT(kwargs[0]), VAL2MAT4(dest));
253
+ } else {
254
+ float padding = NUM2FLT(kwargs[0]);
255
+ float paddingz = NUM2FLT(kwargs[1]);
256
+ glm_ortho(box.corners[0][0] - padding, box.corners[1][0] + padding,
257
+ box.corners[0][1] - padding, box.corners[1][1] + padding,
258
+ -(box.corners[1][2] + paddingz), -(box.corners[0][2] - paddingz),
259
+ VAL2MAT4(dest));
260
+ }
261
+ }
262
+ return dest;
263
+ }
264
+
265
+ /* call-seq: ortho([dest], left:, right:, bottom:, top:, near:, far:) => dest | new Mat4
266
+ *
267
+ * Sets up an orthographic projection matrix. `dest` is a Mat4. If it is
268
+ * omitted, it is created.
269
+ *
270
+ * * `left` is the viewport left
271
+ * * `right` is the viewport right
272
+ * * `bottom` is the viewport bottom
273
+ * * `top` is the viewport top
274
+ * * `near` is the near clipping plane
275
+ * * `far` is the far clipping plane
276
+ * * `dest` is the result matrix
277
+ *
278
+ */
279
+ VALUE rb_cglm_cam_ortho(int argc, VALUE *argv, VALUE klass) {
280
+ static ID kwargs_ids[6];
281
+ if (!kwargs_ids[0]) {
282
+ kwargs_ids[0] = rb_intern_const("left");
283
+ kwargs_ids[1] = rb_intern_const("right");
284
+ kwargs_ids[2] = rb_intern_const("bottom");
285
+ kwargs_ids[3] = rb_intern_const("top");
286
+ kwargs_ids[4] = rb_intern_const("near");
287
+ kwargs_ids[5] = rb_intern_const("far");
288
+ };
289
+ VALUE dest, kwargs[6], opts;
290
+ rb_scan_args(argc, argv, "01:", &dest, &opts);
291
+ rb_get_kwargs(opts, kwargs_ids, 6, 0, kwargs);
292
+ if (NIL_P(dest)) dest = MAT4_NEW(ALLOC_MAT4);
293
+ glm_ortho(NUM2FLT(kwargs[0]),
294
+ NUM2FLT(kwargs[1]),
295
+ NUM2FLT(kwargs[2]),
296
+ NUM2FLT(kwargs[3]),
297
+ NUM2FLT(kwargs[4]),
298
+ NUM2FLT(kwargs[5]),
299
+ VAL2MAT4(dest));
300
+ return dest;
301
+ }
302
+
303
+ /* call-seq: frustum([dest], left:, right:, bottom:, top:, near:, far:) => dest | new Mat4
304
+ *
305
+ * Sets up a perspective projection matrix. `dest` is a Mat4. If it is
306
+ * omitted, it is created.
307
+ *
308
+ * * `left` is the viewport left
309
+ * * `right` is the viewport right
310
+ * * `bottom` is the viewport bottom
311
+ * * `top` is the viewport top
312
+ * * `near` is the near clipping plane
313
+ * * `far` is the far clipping plane
314
+ * * `dest` is the result matrix
315
+ *
316
+ */
317
+ VALUE rb_cglm_cam_frustum(int argc, VALUE *argv, VALUE klass) {
318
+ static ID kwargs_ids[6];
319
+ if (!kwargs_ids[0]) {
320
+ kwargs_ids[0] = rb_intern_const("left");
321
+ kwargs_ids[1] = rb_intern_const("right");
322
+ kwargs_ids[2] = rb_intern_const("bottom");
323
+ kwargs_ids[3] = rb_intern_const("top");
324
+ kwargs_ids[4] = rb_intern_const("near");
325
+ kwargs_ids[5] = rb_intern_const("far");
326
+ };
327
+ VALUE dest, kwargs[6], opts;
328
+ rb_scan_args(argc, argv, "01:", &dest, &opts);
329
+ rb_get_kwargs(opts, kwargs_ids, 6, 0, kwargs);
330
+ if (NIL_P(dest)) dest = MAT4_NEW(ALLOC_MAT4);
331
+ glm_frustum(NUM2FLT(kwargs[0]),
332
+ NUM2FLT(kwargs[1]),
333
+ NUM2FLT(kwargs[2]),
334
+ NUM2FLT(kwargs[3]),
335
+ NUM2FLT(kwargs[4]),
336
+ NUM2FLT(kwargs[5]),
337
+ VAL2MAT4(dest));
338
+ return dest;
339
+ }
340
+
341
+ void Init_cglm_cam() {
342
+ rb_define_method(rb_cMat4, "perspective_resize!", rb_cglm_cam_perspective_resize_self, 1);
343
+ rb_define_method(rb_cMat4, "frustum", rb_cglm_cam_frustum_decomp, 0);
344
+ rb_define_method(rb_cMat4, "left_and_right", rb_cglm_cam_decomp_left_and_right, 0);
345
+ rb_define_method(rb_cMat4, "top_and_bottom", rb_cglm_cam_decomp_top_and_bottom, 0);
346
+ rb_define_method(rb_cMat4, "near_and_far", rb_cglm_cam_decomp_near_and_far, 0);
347
+ rb_define_method(rb_cMat4, "left", rb_cglm_cam_decomp_left, 0);
348
+ rb_define_method(rb_cMat4, "right", rb_cglm_cam_decomp_right, 0);
349
+ rb_define_method(rb_cMat4, "top", rb_cglm_cam_decomp_top, 0);
350
+ rb_define_method(rb_cMat4, "bottom", rb_cglm_cam_decomp_bottom, 0);
351
+ rb_define_method(rb_cMat4, "near", rb_cglm_cam_decomp_near, 0);
352
+ rb_define_method(rb_cMat4, "far", rb_cglm_cam_decomp_far, 0);
353
+ rb_define_method(rb_cMat4, "fovy", rb_cglm_cam_decomp_fovy, 0);
354
+ rb_define_method(rb_cMat4, "aspect", rb_cglm_cam_decomp_aspect, 0);
355
+ rb_define_method(rb_cMat4, "sizes", rb_cglm_cam_sizes, -1);
356
+
357
+ rb_define_singleton_method(rb_cMat4, "frustum", rb_cglm_cam_frustum, -1);
358
+ rb_define_singleton_method(rb_cMat4, "ortho", rb_cglm_cam_ortho, -1);
359
+ rb_define_singleton_method(rb_cMat4, "ortho_aabb", rb_cglm_cam_ortho_aabb, -1);
360
+ rb_define_singleton_method(rb_cMat4, "ortho_unit", rb_cglm_cam_ortho_unit, -1);
361
+ rb_define_singleton_method(rb_cMat4, "ortho_cube", rb_cglm_cam_ortho_cube, -1);
362
+ rb_define_singleton_method(rb_cMat4, "perspective", rb_cglm_cam_perspective, -1);
363
+ rb_define_singleton_method(rb_cMat4, "look_at", rb_cglm_cam_look_at, -1);
364
+ rb_define_singleton_method(rb_cMat4, "look", rb_cglm_cam_look, -1);
365
+ }
@@ -0,0 +1,23 @@
1
+ #include "rb_cglm.h"
2
+
3
+ /* call-seq: luminance => number
4
+ *
5
+ * Averages the RGB color channels into one value
6
+ */
7
+ VALUE rb_cglm_color_luminance3(VALUE self) {
8
+ return DBL2NUM(glm_luminance(VAL2VEC3(self)));
9
+ }
10
+
11
+ /* call-seq: luminance => number
12
+ *
13
+ * Averages the RGB color channels into one value and then multiplies the
14
+ * result by the alpha channel.
15
+ */
16
+ VALUE rb_cglm_color_luminance4(VALUE self) {
17
+ return DBL2NUM(glm_luminance(VAL2VEC3(self)) * VAL2VEC4(self)[3]);
18
+ }
19
+
20
+ void Init_cglm_color() {
21
+ rb_define_method(rb_cVec3, "luminance", rb_cglm_color_luminance3, 0);
22
+ rb_define_method(rb_cVec4, "luminance", rb_cglm_color_luminance4, 0);
23
+ }
@@ -0,0 +1,160 @@
1
+ #include "rb_cglm.h"
2
+
3
+ VALUE rb_cglm_ease_linear(VALUE self, VALUE val) {
4
+ return DBL2NUM(glm_ease_linear(NUM2FLT(val)));
5
+ }
6
+
7
+ VALUE rb_cglm_ease_sine_in(VALUE self, VALUE val) {
8
+ return DBL2NUM(glm_ease_sine_in(NUM2FLT(val)));
9
+ }
10
+
11
+ VALUE rb_cglm_ease_sine_out(VALUE self, VALUE val) {
12
+ return DBL2NUM(glm_ease_sine_out(NUM2FLT(val)));
13
+ }
14
+
15
+ VALUE rb_cglm_ease_sine_inout(VALUE self, VALUE val) {
16
+ return DBL2NUM(glm_ease_sine_inout(NUM2FLT(val)));
17
+ }
18
+
19
+ VALUE rb_cglm_ease_quad_in(VALUE self, VALUE val) {
20
+ return DBL2NUM(glm_ease_quad_in(NUM2FLT(val)));
21
+ }
22
+
23
+ VALUE rb_cglm_ease_quad_out(VALUE self, VALUE val) {
24
+ return DBL2NUM(glm_ease_quad_out(NUM2FLT(val)));
25
+ }
26
+
27
+ VALUE rb_cglm_ease_quad_inout(VALUE self, VALUE val) {
28
+ return DBL2NUM(glm_ease_quad_inout(NUM2FLT(val)));
29
+ }
30
+
31
+ VALUE rb_cglm_ease_cubic_in(VALUE self, VALUE val) {
32
+ return DBL2NUM(glm_ease_cubic_in(NUM2FLT(val)));
33
+ }
34
+
35
+ VALUE rb_cglm_ease_cubic_out(VALUE self, VALUE val) {
36
+ return DBL2NUM(glm_ease_cubic_out(NUM2FLT(val)));
37
+ }
38
+
39
+ VALUE rb_cglm_ease_cubic_inout(VALUE self, VALUE val) {
40
+ return DBL2NUM(glm_ease_cubic_inout(NUM2FLT(val)));
41
+ }
42
+
43
+ VALUE rb_cglm_ease_quart_in(VALUE self, VALUE val) {
44
+ return DBL2NUM(glm_ease_quart_in(NUM2FLT(val)));
45
+ }
46
+
47
+ VALUE rb_cglm_ease_quart_out(VALUE self, VALUE val) {
48
+ return DBL2NUM(glm_ease_quart_out(NUM2FLT(val)));
49
+ }
50
+
51
+ VALUE rb_cglm_ease_quart_inout(VALUE self, VALUE val) {
52
+ return DBL2NUM(glm_ease_quart_inout(NUM2FLT(val)));
53
+ }
54
+
55
+ VALUE rb_cglm_ease_quint_in(VALUE self, VALUE val) {
56
+ return DBL2NUM(glm_ease_quint_in(NUM2FLT(val)));
57
+ }
58
+
59
+ VALUE rb_cglm_ease_quint_out(VALUE self, VALUE val) {
60
+ return DBL2NUM(glm_ease_quint_out(NUM2FLT(val)));
61
+ }
62
+
63
+ VALUE rb_cglm_ease_quint_inout(VALUE self, VALUE val) {
64
+ return DBL2NUM(glm_ease_quint_inout(NUM2FLT(val)));
65
+ }
66
+
67
+ VALUE rb_cglm_ease_exp_in(VALUE self, VALUE val) {
68
+ return DBL2NUM(glm_ease_exp_in(NUM2FLT(val)));
69
+ }
70
+
71
+ VALUE rb_cglm_ease_exp_out(VALUE self, VALUE val) {
72
+ return DBL2NUM(glm_ease_exp_out(NUM2FLT(val)));
73
+ }
74
+
75
+ VALUE rb_cglm_ease_exp_inout(VALUE self, VALUE val) {
76
+ return DBL2NUM(glm_ease_exp_inout(NUM2FLT(val)));
77
+ }
78
+
79
+ VALUE rb_cglm_ease_circ_in(VALUE self, VALUE val) {
80
+ return DBL2NUM(glm_ease_circ_in(NUM2FLT(val)));
81
+ }
82
+
83
+ VALUE rb_cglm_ease_circ_out(VALUE self, VALUE val) {
84
+ return DBL2NUM(glm_ease_circ_out(NUM2FLT(val)));
85
+ }
86
+
87
+ VALUE rb_cglm_ease_circ_inout(VALUE self, VALUE val) {
88
+ return DBL2NUM(glm_ease_circ_inout(NUM2FLT(val)));
89
+ }
90
+
91
+ VALUE rb_cglm_ease_back_in(VALUE self, VALUE val) {
92
+ return DBL2NUM(glm_ease_back_in(NUM2FLT(val)));
93
+ }
94
+
95
+ VALUE rb_cglm_ease_back_out(VALUE self, VALUE val) {
96
+ return DBL2NUM(glm_ease_back_out(NUM2FLT(val)));
97
+ }
98
+
99
+ VALUE rb_cglm_ease_back_inout(VALUE self, VALUE val) {
100
+ return DBL2NUM(glm_ease_back_inout(NUM2FLT(val)));
101
+ }
102
+
103
+ VALUE rb_cglm_ease_elast_in(VALUE self, VALUE val) {
104
+ return DBL2NUM(glm_ease_elast_in(NUM2FLT(val)));
105
+ }
106
+
107
+ VALUE rb_cglm_ease_elast_out(VALUE self, VALUE val) {
108
+ return DBL2NUM(glm_ease_elast_out(NUM2FLT(val)));
109
+ }
110
+
111
+ VALUE rb_cglm_ease_elast_inout(VALUE self, VALUE val) {
112
+ return DBL2NUM(glm_ease_elast_inout(NUM2FLT(val)));
113
+ }
114
+
115
+ VALUE rb_cglm_ease_bounce_out(VALUE self, VALUE val) {
116
+ return DBL2NUM(glm_ease_bounce_out(NUM2FLT(val)));
117
+ }
118
+
119
+ VALUE rb_cglm_ease_bounce_in(VALUE self, VALUE val) {
120
+ return DBL2NUM(glm_ease_bounce_in(NUM2FLT(val)));
121
+ }
122
+
123
+ VALUE rb_cglm_ease_bounce_inout(VALUE self, VALUE val) {
124
+ return DBL2NUM(glm_ease_bounce_inout(NUM2FLT(val)));
125
+ }
126
+
127
+ void Init_cglm_ease() {
128
+ VALUE rb_mEasing = rb_define_module_under(rb_mCGLM, "Easing");
129
+ rb_define_method(rb_mEasing, "linear", rb_cglm_ease_linear, 1);
130
+ rb_define_method(rb_mEasing, "sine_in", rb_cglm_ease_sine_in, 1);
131
+ rb_define_method(rb_mEasing, "sine_out", rb_cglm_ease_sine_out, 1);
132
+ rb_define_method(rb_mEasing, "sine_inout", rb_cglm_ease_sine_inout, 1);
133
+ rb_define_method(rb_mEasing, "quad_in", rb_cglm_ease_quad_in, 1);
134
+ rb_define_method(rb_mEasing, "quad_out", rb_cglm_ease_quad_out, 1);
135
+ rb_define_method(rb_mEasing, "quad_inout", rb_cglm_ease_quad_inout, 1);
136
+ rb_define_method(rb_mEasing, "cubic_in", rb_cglm_ease_cubic_in, 1);
137
+ rb_define_method(rb_mEasing, "cubic_out", rb_cglm_ease_cubic_out, 1);
138
+ rb_define_method(rb_mEasing, "cubic_inout", rb_cglm_ease_cubic_inout, 1);
139
+ rb_define_method(rb_mEasing, "quart_in", rb_cglm_ease_quart_in, 1);
140
+ rb_define_method(rb_mEasing, "quart_out", rb_cglm_ease_quart_out, 1);
141
+ rb_define_method(rb_mEasing, "quart_inout", rb_cglm_ease_quart_inout, 1);
142
+ rb_define_method(rb_mEasing, "quint_in", rb_cglm_ease_quint_in, 1);
143
+ rb_define_method(rb_mEasing, "quint_out", rb_cglm_ease_quint_out, 1);
144
+ rb_define_method(rb_mEasing, "quint_inout", rb_cglm_ease_quint_inout, 1);
145
+ rb_define_method(rb_mEasing, "exp_in", rb_cglm_ease_exp_in, 1);
146
+ rb_define_method(rb_mEasing, "exp_out", rb_cglm_ease_exp_out, 1);
147
+ rb_define_method(rb_mEasing, "exp_inout", rb_cglm_ease_exp_inout, 1);
148
+ rb_define_method(rb_mEasing, "circ_in", rb_cglm_ease_circ_in, 1);
149
+ rb_define_method(rb_mEasing, "circ_out", rb_cglm_ease_circ_out, 1);
150
+ rb_define_method(rb_mEasing, "circ_inout", rb_cglm_ease_circ_inout, 1);
151
+ rb_define_method(rb_mEasing, "back_in", rb_cglm_ease_back_in, 1);
152
+ rb_define_method(rb_mEasing, "back_out", rb_cglm_ease_back_out, 1);
153
+ rb_define_method(rb_mEasing, "back_inout", rb_cglm_ease_back_inout, 1);
154
+ rb_define_method(rb_mEasing, "elast_in", rb_cglm_ease_elast_in, 1);
155
+ rb_define_method(rb_mEasing, "elast_out", rb_cglm_ease_elast_out, 1);
156
+ rb_define_method(rb_mEasing, "elast_inout", rb_cglm_ease_elast_inout, 1);
157
+ rb_define_method(rb_mEasing, "bounce_out", rb_cglm_ease_bounce_out, 1);
158
+ rb_define_method(rb_mEasing, "bounce_in", rb_cglm_ease_bounce_in, 1);
159
+ rb_define_method(rb_mEasing, "bounce_inout", rb_cglm_ease_bounce_inout, 1);
160
+ }